Debian Codegraph @

js/src/tests/test262/intl402/Temporal/ZonedDateTime/etc-timezone.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.zoneddatetime
7 description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all
8 features: [Temporal, canonical-tz]
9 ---*/
10
11 // "Etc/GMT-0" through "Etc/GMT-14" are OK
12
13 [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => {
14 let tz = "Etc/GMT-" + n;
15 let instance = new Temporal.ZonedDateTime(0n, tz);
16 assert.sameValue(
17 instance.timeZoneId,
18 tz,
19 tz + " is a valid timezone"
20 );
21 });
22
23 let gmtMinus24TZ = "Etc/GMT-24";
24 assert.throws(
25 RangeError,
26 () => { new Temporal.ZonedDateTime(0n, gmtMinus24TZ); },
27 gmtMinus24TZ + " is an invalid timezone"
28 );
29
30 // "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9)
31 [1,2,3,4,5,6,7,8,9].forEach((n) => {
32 let tz = "Etc/GMT-0" + n;
33 assert.throws(
34 RangeError,
35 () => { new Temporal.ZonedDateTime(0n, tz); },
36 tz + " is an invalid timezone"
37 );
38 });
39
40 // "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9)
41 [0,1,2,3,4,5,6,7,8,9].forEach((n) => {
42 let tz = "Etc/GMT+0" + n;
43 assert.throws(
44 RangeError,
45 () => { new Temporal.ZonedDateTime(0n, tz); },
46 tz + " is an invalid timezone"
47 );
48 });
49
50 // Etc/GMT+0" through "Etc/GMT+12" are OK
51
52 [0,1,2,3,4,5,6,7,8,9,10,11,12].forEach((n) => {
53 let tz = "Etc/GMT+" + n;
54 let instance = new Temporal.ZonedDateTime(0n, tz);
55 assert.sameValue(
56 instance.timeZoneId,
57 tz,
58 tz + " is a valid timezone"
59 );
60 });
61
62 let gmtPlus24TZ = "Etc/GMT+24";
63 assert.throws(
64 RangeError,
65 () => { new Temporal.ZonedDateTime(0n, gmtPlus24TZ); },
66 gmtPlus24TZ + " is an invalid timezone"
67 );
68
69 reportCompare(0, 0);