Temporal: Avoid recalculating offset ns after GetPlainDateTimeFor

This commit is contained in:
Philip Chimento 2023-03-02 12:41:22 -08:00 committed by Philip Chimento
parent 0c87a86b58
commit c372de0bbe
6 changed files with 28 additions and 14 deletions

View File

@ -24,8 +24,6 @@ const expected = [
"has options.timeZone.id",
"get options.timeZone.getOffsetNanosecondsFor",
"call options.timeZone.getOffsetNanosecondsFor",
"get options.timeZone.getOffsetNanosecondsFor",
"call options.timeZone.getOffsetNanosecondsFor",
];
const actual = [];

View File

@ -3,7 +3,8 @@
/*---
esid: sec-temporal.instant.prototype.tostring
description: Passing a TimeZone to options calls getOffsetNanosecondsFor twice, but not toString
description: >
Passing a TimeZone to options calls getOffsetNanosecondsFor, but not toString
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
@ -15,8 +16,6 @@ const expected = [
"has timeZone.id",
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
];
const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456Z");

View File

@ -13,8 +13,6 @@ features: [Temporal]
const expected = [
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
];
const actual = [];

View File

@ -31,9 +31,6 @@ const expected = [
"call this.calendar.dateAdd",
"get this.timeZone.getPossibleInstantsFor",
"call this.timeZone.getPossibleInstantsFor",
// GetOffsetNanosecondsFor
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
// InterpretISODateTimeOffset
"get this.timeZone.getPossibleInstantsFor",
"call this.timeZone.getPossibleInstantsFor",

View File

@ -0,0 +1,26 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.tojson
description: Properties on objects passed to toJSON() are accessed in the correct order
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expected = [
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.id",
"get this.calendar.id",
];
const actual = [];
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
// clear observable operations that occurred during the constructor call
actual.splice(0);
instance.toJSON();
assert.compareArray(actual, expected, "order of operations");

View File

@ -29,8 +29,6 @@ const expected = [
"call options.timeZoneName.toString",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.id",
"get this.calendar.id",
];
@ -75,8 +73,6 @@ const expectedForFractionalSecondDigits = [
"call options.timeZoneName.toString",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.id",
"get this.calendar.id",
];