diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-04-23 15:14:42 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-24 00:33:25 +0200 |
commit | 5dac3d9f846d0a9cffb95608219fefd4079a7bc2 (patch) | |
tree | af71dea03eb2fd7c46e3e584380e7007d2a78eea /tests/auto/qml/qqmlecmascript/data/exportDate.3.qml | |
parent | a8e017fbc22d8ec445fc9202479a775bdac4d5b0 (diff) |
Verify that QML can reliably receive datetime info from C++
Since a JavaScript Date object does not contain any information about
the timezone in which it is specified, a C++ module that exports
datetime information to QML must also provide the relevant timezone
data so that clients can correctly interpret the datetime value.
Provide an example of exporting datetime information to QML, verifying
that the data can be correctly interpreted in JS.
Task-number: QTBUG-25262
Change-Id: I732797da225861470e6b034f2e3d89a43df36cf7
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/data/exportDate.3.qml')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/exportDate.3.qml | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/exportDate.3.qml b/tests/auto/qml/qqmlecmascript/data/exportDate.3.qml new file mode 100644 index 0000000000..2ba1cc6607 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/exportDate.3.qml @@ -0,0 +1,39 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyTypeObject { + boolProperty: false + + Component.onCompleted: { + var dt = datetimeExporter.getDateTime() + var offset = datetimeExporter.getDateTimeOffset() + var date = datetimeExporter.getDate() + var timespec = datetimeExporter.getTimeSpec() + + // The test date is 2009-5-12 00:00:01 (UTC) + var compare = new Date(Date.UTC(2009, 5-1, 12, 0, 0, 1)) + var compareOffset = 0 + + // Adjust for timezone to extract correct partial values + var dtAdjusted = new Date(dt.getUTCFullYear(), + dt.getUTCMonth(), + dt.getUTCDate(), + dt.getUTCHours(), + dt.getUTCMinutes(), + dt.getUTCSeconds(), + dt.getUTCMilliseconds()) + + boolProperty = (dt.getTime() == compare.getTime()) && + (offset == compareOffset) && + (timespec == 'UTC') && + (dtAdjusted.getFullYear() == 2009) && + (dtAdjusted.getMonth() == 5-1) && + (dtAdjusted.getDate() == 12) && + (dtAdjusted.getHours() == 0) && + (dtAdjusted.getMinutes() == 0) && + (dtAdjusted.getSeconds() == 1) && + (date.getFullYear() == 2009) && + (date.getMonth() == 5-1) && + (date.getDate() == 12) + } +} |