Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/leap-second.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.compare
7 description: Leap second is a valid ISO string for ZonedDateTime
8 features: [Temporal]
9 ---*/
10
11 const datetime = new Temporal.ZonedDateTime(1_483_228_799_000_000_000n, "UTC");
12
13 let arg = "2016-12-31T23:59:60+00:00[UTC]";
14 const result1 = Temporal.ZonedDateTime.compare(arg, datetime);
15 assert.sameValue(result1, 0, "leap second is a valid ISO string for ZonedDateTime (first argument)");
16 const result2 = Temporal.ZonedDateTime.compare(datetime, arg);
17 assert.sameValue(result2, 0, "leap second is a valid ISO string for ZonedDateTime (second argument)");
18
19 arg = "2000-05-02T12:34:56+23:59[+23:59:60]";
20 assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime), "leap second in time zone name not valid (first argument)");
21 assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg), "leap second in time zone name not valid (second argument)");
22
23 reportCompare(0, 0);