Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.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.zoneddatetime.compare
7 description: Sub-minute offset trailing zeroes allowed in ISO string but not in bracketed offset
8 features: [Temporal]
9 ---*/
10
11 const datetime = new Temporal.ZonedDateTime(30_000_000_000n, "+01:35");
12 let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]";
13
14 assert.sameValue(
15 Temporal.ZonedDateTime.compare(str, datetime),
16 0,
17 "Time zone determined from bracket name (first argument)"
18 );
19 assert.sameValue(
20 Temporal.ZonedDateTime.compare(datetime, str),
21 0,
22 "Time zone determined from bracket name (second argument)"
23 );
24
25 str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]";
26 assert.throws(
27 RangeError,
28 () => Temporal.ZonedDateTime.compare(str, datetime),
29 "Trailing zeroes not allowed for sub-minute time zone identifiers (first argument)"
30 );
31 assert.throws(
32 RangeError,
33 () => Temporal.ZonedDateTime.compare(datetime, str),
34 "Trailing zeroes not allowed for sub-minute time zone identifiers (second argument)"
35 );
36
37 reportCompare(0, 0);