From 948e24cb6deeaf0e55794032b90fdf20b7ef12c1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 3 Nov 2016 19:00:24 +0100 Subject: V4 Date.ParseString(): fix UTC-ness of date-only formats ECMA-262 stipulates that date-only formats should be treated as UTC, while date-times are handled as standard time, if no time zone is explicitly given. Tidied up the parser a bit in the process and documented what the spec says. Fixed some broken test-cases. Handling of date-times without zone as local time is a correction since edition 5.1 of ECMA-262 (which said to handle it as UTC): http://www.ecma-international.org/ecma-262/7.0/index.html#sec-corrections-and-clarifications-in-ecmascript-2015-with-possible-compatibility-impact We were previously handling both dates and date-times as local time, violating the old spec for both and the revised spec for dates. Task-number: QTBUG-56787 Change-Id: I557789d855b910ca6a859fca396af1a0205c9417 Reviewed-by: Qt CI Bot Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/auto/qml/qqmlqt/tst_qqmlqt.cpp') diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 0576650d01..6c920471c4 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -888,7 +888,8 @@ void tst_qqmlqt::dateTimeFormattingVariants_data() QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); QDate date(2011,5,31); - temporary = QDateTime(date); + // V4 reads the date in UTC but DateObject::toQDateTime() gives it back in local time: + temporary = QDateTime(date, QTime(0, 0, 0), Qt::UTC).toLocalTime(); QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); -- cgit v1.2.3