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}
*/
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
}
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"));