diff options
Diffstat (limited to 'tests/auto/qml/qqmllocale/data/timeZoneUpdated.qml')
-rw-r--r-- | tests/auto/qml/qqmllocale/data/timeZoneUpdated.qml | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllocale/data/timeZoneUpdated.qml b/tests/auto/qml/qqmllocale/data/timeZoneUpdated.qml new file mode 100644 index 0000000000..92d1f5bc40 --- /dev/null +++ b/tests/auto/qml/qqmllocale/data/timeZoneUpdated.qml @@ -0,0 +1,51 @@ +import QtQuick 2.0 + +Item { + property bool success: false + + property date localDate + property date utcDate + + Component.onCompleted: { + // Test date: 2012-06-01T02:15:30+10:00 (AEST timezone) + localDate = new Date(2012, 6-1, 1, 2, 15, 30) + utcDate = new Date(Date.UTC(2012, 6-1, 1, 2, 15, 30)) + + if (localDate.getTimezoneOffset() != -600) return + + if (localDate.toLocaleString() != "Friday, June 1, 2012 2:15:30 AM AEST") return + if (localDate.toISOString() != "2012-05-31T16:15:30.000Z") return + + if (utcDate.toISOString() != "2012-06-01T02:15:30.000Z") return + if (utcDate.toLocaleString() != "Friday, June 1, 2012 12:15:30 PM AEST") return + + success = true + } + + function check() { + success = false + + // We have changed to IST time zone - inform JS: + Date.timeZoneUpdated() + + if (localDate.getTimezoneOffset() != -330) return + + if (localDate.toLocaleString() != "Friday, June 1, 2012 2:15:30 AM IST") return + if (localDate.toISOString() != "2012-05-31T20:45:30.000Z") return + + if (utcDate.toISOString() != "2012-06-01T06:45:30.000Z") return + if (utcDate.toLocaleString() != "Friday, June 1, 2012 12:15:30 PM IST") return + + // Create new dates in this timezone + localDate = new Date(2012, 6-1, 1, 2, 15, 30) + utcDate = new Date(Date.UTC(2012, 6-1, 1, 2, 15, 30)) + + if (localDate.toLocaleString() != "Friday, June 1, 2012 2:15:30 AM IST") return + if (localDate.toISOString() != "2012-05-31T20:45:30.000Z") return + + if (utcDate.toISOString() != "2012-06-01T02:15:30.000Z") return + if (utcDate.toLocaleString() != "Friday, June 1, 2012 7:45:30 AM IST") return + + success = true + } +} |