summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Temporal/TimeZone/etc-timezone.js
blob: 7703f6b58ff96527d8dd2bc83c6b1a7188dd9d4e (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
63
64
65
66
67
68
69
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.timezone
description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all
features: [Temporal]
---*/

// "Etc/GMT-0" through "Etc/GMT-14" are OK

[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => {
  let tz = "Etc/GMT-" + n;
  let instance = new Temporal.TimeZone(tz);
  assert.sameValue(
    instance.toString(),
    tz,
    tz + " is a valid timezone"
  );
});

let gmtMinus24TZ = "Etc/GMT-24";
assert.throws(
  RangeError,
  () => { new Temporal.TimeZone(gmtMinus24TZ); },
  gmtMinus24TZ + " is an invalid timezone"
);

// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9)
[1,2,3,4,5,6,7,8,9].forEach((n) => {
  let tz = "Etc/GMT-0" + n;
  assert.throws(
    RangeError,
    () => { new Temporal.TimeZone(tz); },
    tz + " is an invalid timezone"
  );
});

// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9)
[0,1,2,3,4,5,6,7,8,9].forEach((n) => {
  let tz = "Etc/GMT+0" + n;
  assert.throws(
    RangeError,
    () => { new Temporal.TimeZone(tz); },
    tz + " is an invalid timezone"
    );
});

// Etc/GMT+0" through "Etc/GMT+12" are OK

[0,1,2,3,4,5,6,7,8,9,10,11,12].forEach((n) => {
  let tz = "Etc/GMT+" + n;
  let instance = new Temporal.TimeZone(tz);
  assert.sameValue(
    instance.toString(),
    tz,
    tz + " is a valid timezone"
  );
});

let gmtPlus24TZ = "Etc/GMT+24";
assert.throws(
  RangeError,
  () => { new Temporal.TimeZone(gmtPlus24TZ); },
  gmtPlus24TZ + " is an invalid timezone"
);

reportCompare(0, 0);