Bug 1904139 - Don't re-initialize platform font list from GetDefaultFont. r=jfkthame
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / ZonedDateTime / prototype / equals / zoneddatetime-string.js
blob127adda14b7c146f9382a82a8a5fac91377128d2
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: sec-temporal.zoneddatetime.prototype.equals
7 description: Conversion of ISO date-time strings to Temporal.ZonedDateTime instances
8 features: [Temporal]
9 ---*/
11 const timeZone = new Temporal.TimeZone("+01:00");
12 const instance = new Temporal.ZonedDateTime(0n, timeZone);
14 let str = "1970-01-01T00:00";
15 assert.throws(RangeError, () => instance.equals(str), "bare date-time string is not a ZonedDateTime");
16 str = "1970-01-01T00:00Z";
17 assert.throws(RangeError, () => instance.equals(str), "date-time + Z is not a ZonedDateTime");
18 str = "1970-01-01T00:00+01:00";
19 assert.throws(RangeError, () => instance.equals(str), "date-time + offset is not a ZonedDateTime");
21 str = "1970-01-01T00:00[+01:00]";
22 const result1 = instance.equals(str);
23 assert.sameValue(result1, false, "date-time + IANA annotation preserves wall time in the time zone");
25 str = "1970-01-01T00:00Z[+01:00]";
26 const result2 = instance.equals(str);
27 assert.sameValue(result2, true, "date-time + Z + IANA annotation preserves exact time in the time zone");
29 str = "1970-01-01T00:00+01:00[+01:00]";
30 const result3 = instance.equals(str);
31 assert.sameValue(result3, false, "date-time + offset + IANA annotation ensures both exact and wall time match");
33 str = "1970-01-01T00:00-04:15[+01:00]";
34 assert.throws(RangeError, () => instance.equals(str), "date-time + offset + IANA annotation throws if wall time and exact time mismatch");
36 reportCompare(0, 0);