Debian Codegraph @

tests/auto/qml/qqmllocale/data/timeZoneUpdated.qml

raw
1 import QtQuick 2.0
2
3 Item {
4 property bool success: false
5
6 property date localDate
7 property date utcDate
8
9 Component.onCompleted: {
10 // Test date: 2012-06-01T02:15:30+10:00 (AEST timezone)
11 localDate = new Date(2012, 6-1, 1, 2, 15, 30)
12 utcDate = new Date(Date.UTC(2012, 6-1, 1, 2, 15, 30))
13
14 if (localDate.getTimezoneOffset() != -600) return
15
16 if (localDate.toLocaleString() != getLocalizedForm('2012-06-01T02:15:30')) return
17 if (localDate.toISOString() != "2012-05-31T16:15:30.000Z") return
18
19 if (utcDate.toISOString() != "2012-06-01T02:15:30.000Z") return
20 if (utcDate.toLocaleString() != getLocalizedForm('2012-06-01T12:15:30')) return
21
22 success = true
23 }
24
25 function check() {
26 success = false
27
28 // We have changed to IST time zone - inform JS:
29 Date.timeZoneUpdated()
30
31 if (localDate.getTimezoneOffset() != -330) return
32
33 if (localDate.toLocaleString() != getLocalizedForm('2012-06-01T02:15:30')) return
34 if (localDate.toISOString() != "2012-05-31T20:45:30.000Z") return
35
36 if (utcDate.toISOString() != "2012-06-01T06:45:30.000Z") return
37 if (utcDate.toLocaleString() != getLocalizedForm("2012-06-01T12:15:30")) return
38
39 // Create new dates in this timezone
40 localDate = new Date(2012, 6-1, 1, 2, 15, 30)
41 utcDate = new Date(Date.UTC(2012, 6-1, 1, 2, 15, 30))
42
43 if (localDate.toLocaleString() != getLocalizedForm("2012-06-01T02:15:30")) return
44 if (localDate.toISOString() != "2012-05-31T20:45:30.000Z") return
45
46 if (utcDate.toISOString() != "2012-06-01T02:15:30.000Z") return
47 if (utcDate.toLocaleString() != getLocalizedForm("2012-06-01T07:45:30")) return
48
49 success = true
50 }
51
52 function resetTimeZone() {
53 Date.timeZoneUpdated()
54 }
55 }