Stabilize test
authorAlan Alpert <alan.alpert@nokia.com>
Wed, 16 Nov 2011 07:03:56 +0000 (18:03 +1100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 17 Nov 2011 01:52:09 +0000 (02:52 +0100)
Test failed in DST when JS and QDateTime DST methods conflict. The time
in ms since epoch is still correct though, so test data is now within
ranges where they do not conflict (only happens with historical data).

Task-number: QTBUG-22408
Change-Id: I884e28b4681cc10fb25e777d2eabe20d8ac0bce4
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
doc/src/declarative/basictypes.qdoc
tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml
tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp

index d59e599..c128239 100644 (file)
     To read a time value returned from a C++ extension class, use
     \l{QML:Qt::formatTime()}{Qt.formatTime()} and \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
 
+    Note that when converting historical times to and from javascript that QDateTime and the JS Date object
+    have different methods of calculating historical daylight savings time application. This can lead to variations of one hour
+    when converting to historical local time.
+
     \sa {QML Basic Types}
  */
 
index 0620328..4260c8a 100644 (file)
@@ -2,13 +2,13 @@ import QtQuick 1.0
 
 QtObject {
     // months are 0-based - so January = 0, December = 11.
-    property variant qtime: new Date(0,0,0,14,15,38,200)            // yyyy/MM/dd 14:15:38.200
+    property variant qtime: new Date(2000,0,0,14,15,38,200)         // yyyy/MM/dd 14:15:38.200
     property variant qdate: new Date(2008,11,24)                    // 2008/12/24 hh:mm:ss.zzz
     property variant qdatetime: new Date(2008,11,24,14,15,38,200)   // 2008/12/24 14:15:38.200
 
     property variant qdatetime2: new Date(2852,11,31,23,59,59,500)  // 2852/12/31 23:59:59.500
-    property variant qdatetime3: new Date(1970,0,1,0,0,0,0)         // 1970/01/01 00:00:00.000
-    property variant qdatetime4: new Date(1586,1,2)                 // 1586/02/02 hh:mm:ss.zzz
-    property variant qdatetime5: new Date(955,0,1,0,0,0,0)          //  955/01/01 00:00:00.000
-    property variant qdatetime6: new Date(113,1,24,14,15,38,200)    //  113/02/24 14:15:38.200
+    property variant qdatetime3: new Date(2000,0,1,0,0,0,0)         // 2000/01/01 00:00:00.000
+    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
 }
index 83bed2b..d2feb85 100644 (file)
@@ -503,11 +503,13 @@ void tst_qdeclarativeqt::dateTimeConversion()
     QDate date(2008,12,24);
     QTime time(14,15,38,200);
     QDateTime dateTime(date, time);
+    //Note that when converting Date to QDateTime they can argue over historical DST data when converting to local time.
+    //Tests should use UTC or recent dates.
     QDateTime dateTime2(QDate(2852,12,31), QTime(23,59,59,500));
-    QDateTime dateTime3(QDate(1970,1,1), QTime(0,0,0,0));
-    QDateTime dateTime4(QDate(1586,2,2), QTime(0,0,0,0));
-    QDateTime dateTime5(QDate(955,1,1), QTime(0,0,0,0));
-    QDateTime dateTime6(QDate(113,2,24), QTime(14,15,38,200));
+    QDateTime dateTime3(QDate(2000,1,1), QTime(0,0,0,0));
+    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));
 
     QDeclarativeEngine eng;
     QDeclarativeComponent component(&eng, TEST_FILE("dateTimeConversion.qml"));