Debian Codegraph @

js/src/tests/non262/Intl/DateTimeFormat/format_timeZone-non-meta.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
2
3 // Ensure we provide 'long' and 'short' descriptive names for non-meta time
4 // zones. (CLDR stores names for Etc/UTC, Europe/Dublin, and Europe/London as
5 // non-meta zones.)
6
7 const date = new Date(Date.UTC(2018, 7-1, 24));
8 const tests = [
9 {
10 locale: "en-US",
11 timeZoneName: "long",
12 zones: {
13 "Etc/UTC": "7/24/2018, Coordinated Universal Time",
14 "Europe/Dublin": "7/24/2018, Irish Standard Time",
15 "Europe/London": "7/24/2018, British Summer Time",
16 }
17 },
18 {
19 locale: "de",
20 timeZoneName: "long",
21 zones: {
22 "Etc/UTC": "24.7.2018, Koordinierte Weltzeit",
23 "Europe/Dublin": "24.7.2018, Irische Sommerzeit",
24 "Europe/London": "24.7.2018, Britische Sommerzeit",
25 }
26 },
27
28 {
29 locale: "en-US",
30 timeZoneName: "short",
31 zones: {
32 "Europe/Dublin": "7/24/2018, GMT+1",
33 "Europe/London": "7/24/2018, GMT+1",
34 }
35 },
36 {
37 locale: "en-GB",
38 timeZoneName: "short",
39 zones: {
40 "Europe/Dublin": "24/07/2018, GMT+1",
41 "Europe/London": "24/07/2018, BST",
42 }
43 },
44 {
45 locale: "en-IE",
46 timeZoneName: "short",
47 zones: {
48 "Europe/Dublin": "24/7/2018, IST",
49 "Europe/London": "24/7/2018, GMT+1",
50 }
51 },
52 ];
53
54 for (let {locale, timeZoneName, zones} of tests) {
55 for (let [timeZone, expected] of Object.entries(zones)) {
56 assertEq(new Intl.DateTimeFormat(locale, {timeZone, timeZoneName}).format(date),
57 expected);
58 }
59 }
60
61 if (typeof reportCompare === "function")
62 reportCompare(0, 0, "ok");