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.
6 esid: sec-temporal.zoneddatetime
7 description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
9 sec-temporal-totemporalcalendar step 1.b:
10 b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
11 i. Return _temporalCalendarLike_.[[Calendar]].
12 includes: [compareArray.js]
16 const plainDate = new Temporal.PlainDate(2000, 5, 2);
17 const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
18 const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
19 const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
20 const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
22 [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
26 const calendar = arg.getISOFields().calendar;
28 Object.defineProperty(arg, "calendar", {
30 actual.push("get calendar");
35 const result = new Temporal.ZonedDateTime(0n, "UTC", arg);
36 assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
38 assert.compareArray(actual, expected, "calendar getter not called");