summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/DateTimeFormat/format_timeZone-non-meta.js
blob: f3de06bb9709a2c51a41bd6fb7520e0989ba37e6 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// |reftest| skip-if(!this.hasOwnProperty("Intl"))

// Ensure we provide 'long' and 'short' descriptive names for non-meta time
// zones. (CLDR stores names for Etc/UTC, Europe/Dublin, and Europe/London as
// non-meta zones.)

const date = new Date(Date.UTC(2018, 7-1, 24));
const tests = [
    {
        locale: "en-US",
        timeZoneName: "long",
        zones: {
            "Etc/UTC": "7/24/2018, Coordinated Universal Time",
            "Europe/Dublin": "7/24/2018, Irish Standard Time",
            "Europe/London": "7/24/2018, British Summer Time",
        }
    },
    {
        locale: "de",
        timeZoneName: "long",
        zones: {
            "Etc/UTC": "24.7.2018, Koordinierte Weltzeit",
            "Europe/Dublin": "24.7.2018, Irische Sommerzeit",
            "Europe/London": "24.7.2018, Britische Sommerzeit",
        }
    },

    {
        locale: "en-US",
        timeZoneName: "short",
        zones: {
            "Europe/Dublin": "7/24/2018, GMT+1",
            "Europe/London": "7/24/2018, GMT+1",
        }
    },
    {
        locale: "en-GB",
        timeZoneName: "short",
        zones: {
            "Europe/Dublin": "24/07/2018, GMT+1",
            "Europe/London": "24/07/2018, BST",
        }
    },
    {
        locale: "en-IE",
        timeZoneName: "short",
        zones: {
            "Europe/Dublin": "24/7/2018, IST",
            "Europe/London": "24/7/2018, GMT+1",
        }
    },
];

for (let {locale, timeZoneName, zones} of tests) {
    for (let [timeZone, expected] of Object.entries(zones)) {
        assertEq(new Intl.DateTimeFormat(locale, {timeZone, timeZoneName}).format(date),
                 expected);
    }
}

if (typeof reportCompare === "function")
    reportCompare(0, 0, "ok");