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.prototype.since
8 BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the
10 includes: [temporalHelpers.js]
14 const calendar = TemporalHelpers.calendarDateAddUndefinedOptions();
15 const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9);
16 const earlier = new Temporal.ZonedDateTime(0n, timeZone, calendar);
17 const later = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar);
19 // Difference with rounding, with smallestUnit a calendar unit.
20 // The calls come from these paths:
21 // ZonedDateTime.since() ->
23 // MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd()
24 // MoveRelativeDate -> calendar.dateAdd()
25 // BalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd()
27 later.since(earlier, { smallestUnit: "weeks" });
28 assert.sameValue(calendar.dateAddCallCount, 3, "rounding difference with calendar smallestUnit");