Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.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) 2021 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.now.plaintimeiso
7 description: Conversion of ISO date-time strings to time zone IDs
8 features: [Temporal]
9 ---*/
10
11 let timeZone = "2021-08-19T17:30";
12 assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone), "bare date-time string is not a time zone");
13
14 [
15 "2021-08-19T17:30-07:00:01",
16 "2021-08-19T17:30-07:00:00",
17 "2021-08-19T17:30-07:00:00.1",
18 "2021-08-19T17:30-07:00:00.0",
19 "2021-08-19T17:30-07:00:00.01",
20 "2021-08-19T17:30-07:00:00.00",
21 "2021-08-19T17:30-07:00:00.001",
22 "2021-08-19T17:30-07:00:00.000",
23 "2021-08-19T17:30-07:00:00.0001",
24 "2021-08-19T17:30-07:00:00.0000",
25 "2021-08-19T17:30-07:00:00.00001",
26 "2021-08-19T17:30-07:00:00.00000",
27 "2021-08-19T17:30-07:00:00.000001",
28 "2021-08-19T17:30-07:00:00.000000",
29 "2021-08-19T17:30-07:00:00.0000001",
30 "2021-08-19T17:30-07:00:00.0000000",
31 "2021-08-19T17:30-07:00:00.00000001",
32 "2021-08-19T17:30-07:00:00.00000000",
33 "2021-08-19T17:30-07:00:00.000000001",
34 "2021-08-19T17:30-07:00:00.000000000",
35 ].forEach((timeZone) => {
36 assert.throws(
37 RangeError,
38 () => Temporal.Now.plainTimeISO(timeZone),
39 `ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
40 );
41 });
42
43 // The following are all valid strings so should not throw:
44
45 [
46 "2021-08-19T17:30Z",
47 "2021-08-19T1730Z",
48 "2021-08-19T17:30-07:00",
49 "2021-08-19T1730-07:00",
50 "2021-08-19T17:30-0700",
51 "2021-08-19T1730-0700",
52 "2021-08-19T17:30[UTC]",
53 "2021-08-19T1730[UTC]",
54 "2021-08-19T17:30Z[UTC]",
55 "2021-08-19T1730Z[UTC]",
56 "2021-08-19T17:30-07:00[UTC]",
57 "2021-08-19T1730-07:00[UTC]",
58 "2021-08-19T17:30-0700[UTC]",
59 "2021-08-19T1730-0700[UTC]",
60 ].forEach((timeZone) => {
61 Temporal.Now.plainTimeISO(timeZone);
62 });
63
64 reportCompare(0, 0);