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 --- src/qml/jsruntime/qv4engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/jsruntime/qv4engine.cpp') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index b5edad69ae..78cc95b98d 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1370,7 +1370,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant) case QMetaType::QDateTime: return QV4::Encode(newDateObject(*reinterpret_cast(ptr))); case QMetaType::QDate: - return QV4::Encode(newDateObject(QDateTime(*reinterpret_cast(ptr)))); + return QV4::Encode(newDateObject(QDateTime(*reinterpret_cast(ptr), QTime(0, 0, 0), Qt::UTC))); case QMetaType::QTime: return QV4::Encode(newDateObjectFromTime(*reinterpret_cast(ptr))); case QMetaType::QRegExp: -- cgit v1.2.3