summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Date/reset-time-zone-cache-same-offset.js
blob: 56c9fc262c06d5e4b2b5dc4a32693156fa4bee62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable

const testCases = [
    {
        timeZone: "Europe/London",
        string: "Tue Aug 14 2018 00:00:00 GMT+0100 (BST)",
        alternativeTimeZones: ["British Summer Time"],
        localeString: "8/14/2018, 12:00:00 AM GMT+1",
    },
    {
        timeZone: "UTC",
        string: "Tue Aug 14 2018 00:00:00 GMT+0000 (UTC)",
        alternativeTimeZones: ["Coordinated Universal Time"],
        localeString: "8/14/2018, 12:00:00 AM UTC",
    },
];

// Repeat twice to test both transitions (Europe/London -> UTC and UTC -> Europe/London).
for (let i = 0; i < 2; ++i) {
    for (let {timeZone, string, localeString, alternativeTimeZones} of testCases) {
        setTimeZone(timeZone);

        let dt = new Date(2018, 8 - 1, 14);
        assertDateTime(dt, string, ...alternativeTimeZones);
        assertEq(dt.toLocaleString("en-US", {timeZoneName: "short"}), localeString);
    }
}

if (typeof reportCompare === "function")
    reportCompare(true, true);