aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src/cppintegration/data.qdoc
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-07-08 16:40:28 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-10 17:17:15 +0000
commit6e687e85719cf6e8cad218b0307749f7abd049a6 (patch)
tree6b3ac827dda0be334ecc50adcc3832be0781364c /src/qml/doc/src/cppintegration/data.qdoc
parent8bf7cfb7880775f49dfbaf9a2be2202479eaaf99 (diff)
V4: Handle QTime->DateObject conversion better
By specification, date conversion functions for dates before the epoch are not DST corrected. We converted QTime to a QDateTime where we set the date part to Jan. 1, 1970, and then convert that to msecs since the epoch UTC. For places on Earth where they had DST on that day (e.g. Hobart in Australia), strange things happen: conversion from a QTime to DateObject will use DST (because it's after the epoch in local time), but conversions from DateObject to QTime won't use the DST because it's before the epoch (in UTC). Now as everyone knows, a 24-hour clock time has no meaning without a date, only "elapsed time" has. But users still expect to be able to pass QTime to QML/JS. So, we do the conversion on day 0 of month 0 of year 0, and all of it in local time. This gives a stable conversion in both directions, and the values in both C++ and QML/JS are the same for any timezone (with or without DST) on this planet. Task-number: QTBUG-54378 Change-Id: I892e16a93f015e92d311c6cae3ae7768b7373f6a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/qml/doc/src/cppintegration/data.qdoc')
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc
index 7bb4d701e2..cc2fe90483 100644
--- a/src/qml/doc/src/cppintegration/data.qdoc
+++ b/src/qml/doc/src/cppintegration/data.qdoc
@@ -249,6 +249,18 @@ parameter, the value can be created as a JavaScript \c Date object in QML, and
is automatically converted to a QDateTime value when it is passed to C++.
+\section2 QTime to JavaScript Date
+
+The QML engine provides automatic type conversion from QTime values to
+JavaScript \c Date objects. The date component of the resulting Date
+object should not be relied upon, as it is operating system dependent.
+Specifically, the year (and month and day) are set to zero. Conversion
+from a JavaScript \c Date object to QTime is done by converting to a
+QDateTime, and then relying on QVariant to convert it to a QTime. The end
+effect is that the date part of the \c Date object is ignored, but the
+local timezone will be used ignoring any DST complications it may have.
+
+
\section2 Sequence Type to JavaScript Array
Certain C++ sequence types are supported transparently in QML as JavaScript