From f3f95d4282ffbfb307e98d20a166ced4cc982061 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 22 Jun 2010 13:53:03 +0200 Subject: QXmlPatterns QAbstractDateTime: only parse 3 digits of time fraction the XML Schema dateTime type allows for an unlimited precision of fractial time values; this fails for 4 or more digits when creating a QTime. This patch takes only 3 digits of the time fraction into account, since we cannot store more in a QTime or QDateTime anyway. Reviewed-by: Olivier Goffart Task-number: QTBUG-11559 --- src/xmlpatterns/data/qabstractdatetime.cpp | 2 +- .../files/dateTime-with-microseconds.xml | 1 + .../files/dateTime-with-microseconds.xsd | 12 ++++++++++++ tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xml create mode 100644 tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xsd diff --git a/src/xmlpatterns/data/qabstractdatetime.cpp b/src/xmlpatterns/data/qabstractdatetime.cpp index 6329fbe..a298698 100644 --- a/src/xmlpatterns/data/qabstractdatetime.cpp +++ b/src/xmlpatterns/data/qabstractdatetime.cpp @@ -163,7 +163,7 @@ QDateTime AbstractDateTime::create(AtomicValue::Ptr &errorMessage, QString msecondsStr(getSafeCapt(mseconds)); if(!msecondsStr.isEmpty()) - msecondsStr = msecondsStr.leftJustified(3, QLatin1Char('0')); + msecondsStr = msecondsStr.leftJustified(3, QLatin1Char('0'), true); const MSecondProperty msecs = msecondsStr.toInt(); if(hour == 24) diff --git a/tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xml b/tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xml new file mode 100644 index 0000000..b17739a --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xml @@ -0,0 +1 @@ +2009-12-16T23:14:10.823218Z diff --git a/tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xsd b/tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xsd new file mode 100644 index 0000000..55557f1 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/dateTime-with-microseconds.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp index 3517b5a..092e966 100644 --- a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp +++ b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp @@ -216,6 +216,12 @@ void tst_XmlPatternsValidator::xsdSupport_data() const << 0 << (QStringList() << QLatin1String("files/complex-type-including-anonymous-type.xsd")) << QString(); + + QTest::newRow("QTBUG-11559 A schema and instance with a dateTime containing microseconds") + << 0 + << (QStringList() << QLatin1String("files/dateTime-with-microseconds.xml") + << QLatin1String("files/dateTime-with-microseconds.xsd")) + << QString(); } QTEST_MAIN(tst_XmlPatternsValidator) -- cgit v0.12