diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-04-10 17:12:58 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-11 03:35:15 +0200 |
commit | 65bfc35429e845cf6b76d58107360a1360a654fc (patch) | |
tree | 0695964cfcc346137823d94de351cf8812a33bf4 /tests/auto/qml/qqmlqt | |
parent | 80872d0a450d4179e66121d8efe01929ad56fb05 (diff) |
Simplify date conversion functions
Do not use the 3rd-party code from JSC, but instead use the QDateTime
functions for millisecond offsets from the epoch.
Note that this change is reviving the earlier change:
http://codereview.qt-project.org/1874. The test failures for that
change no longer occur due to a change in the QDateTime behavior
applied by: http://codereview.qt-project.org/13169
There is still a semantic difference between QDateTime and the
ECMAScript specification with regards to the application of DST.
ECMAScript requires that the current DST adjustment should be applied
to historical dates, whereas QDateTime will apply the adjustment as
applicable at the epoch date to any prior dates.
Change-Id: Ibebd47c9d2b75a034342ffcda075501a6a527b8d
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlqt')
-rw-r--r-- | tests/auto/qml/qqmlqt/data/dateTimeConversion.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml index 641ba6e1ca..300074dec1 100644 --- a/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml +++ b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml @@ -11,4 +11,10 @@ QtObject { property variant qdatetime4: new Date(2001,1,2) // 2001/02/02 hh:mm:ss.zzz property variant qdatetime5: new Date(1999,0,1,2,3,4) // 1999/01/01 02:03:04.zzz property variant qdatetime6: new Date(2008,1,24,14,15,38,200) // 2008/02/24 14:15:38.200 + + // Use UTC for historical dates to avoid DST issues + property variant qdatetime7: new Date(Date.UTC(1970,0,1,0,0,0,0)) // 1970/01/01 00:00:00.000 + property variant qdatetime8: new Date(Date.UTC(1586,1,2)) // 1586/02/02 hh:mm:ss.zzz + property variant qdatetime9: new Date(Date.UTC(955,0,1,0,0,0,0)) // 955/01/01 00:00:00.000 + property variant qdatetime10: new Date(Date.UTC(113,1,24,14,15,38,200)) // 113/02/24 14:15:38.200 } diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index d3dc3e7343..d4bf23306e 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -478,6 +478,10 @@ void tst_qqmlqt::dateTimeConversion() QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0)); QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0)); QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200)); + QDateTime dateTime7(QDate(1970,1,1), QTime(0,0,0,0), Qt::UTC); + QDateTime dateTime8(QDate(1586,2,2), QTime(0,0,0,0), Qt::UTC); + QDateTime dateTime9(QDate(955,1,1), QTime(0,0,0,0), Qt::UTC); + QDateTime dateTime10(QDate(113,2,24), QTime(14,15,38,200), Qt::UTC); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("dateTimeConversion.qml")); @@ -491,6 +495,10 @@ void tst_qqmlqt::dateTimeConversion() QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4); QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5); QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6); + QCOMPARE(obj->property("qdatetime7").toDateTime(), dateTime7); + QCOMPARE(obj->property("qdatetime8").toDateTime(), dateTime8); + QCOMPARE(obj->property("qdatetime9").toDateTime(), dateTime9); + QCOMPARE(obj->property("qdatetime10").toDateTime(), dateTime10); } void tst_qqmlqt::dateTimeFormatting() |