Store strings or objects in Temporal.ZonedDateTime [[TimeZone]] slot

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
This commit is contained in:
Philip Chimento 2023-02-17 13:06:20 -08:00 committed by Philip Chimento
parent f2871840b8
commit 960070549b
80 changed files with 1686 additions and 335 deletions

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.duration.compare
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
// The following are all valid strings so should not throw:
["UTC", "+01:00"].forEach((timeZone) => {
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,9 +4,27 @@
/*---
esid: sec-temporal.duration.prototype.add
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Duration(1);
// The following are all valid strings so should not throw:
@ -14,3 +32,6 @@ const instance = new Temporal.Duration(1);
["UTC", "+01:00"].forEach((timeZone) => {
instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,9 +4,27 @@
/*---
esid: sec-temporal.duration.prototype.round
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Duration(1);
// The following are all valid strings so should not throw:
@ -14,3 +32,6 @@ const instance = new Temporal.Duration(1);
["UTC", "+01:00"].forEach((timeZone) => {
instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,9 +4,27 @@
/*---
esid: sec-temporal.duration.prototype.subtract
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Duration(1);
// The following are all valid strings so should not throw:
@ -14,3 +32,6 @@ const instance = new Temporal.Duration(1);
["UTC", "+01:00"].forEach((timeZone) => {
instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,9 +4,27 @@
/*---
esid: sec-temporal.duration.prototype.total
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Duration(1);
// The following are all valid strings so should not throw:
@ -14,3 +32,6 @@ const instance = new Temporal.Duration(1);
["UTC", "+01:00"].forEach((timeZone) => {
instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -1,19 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.prototype.tojson
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
const instance = new Temporal.Instant(1_000_000_000_987_654_321n);
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => instance.toJSON(),
`Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
);
});

View File

@ -4,9 +4,27 @@
/*---
esid: sec-temporal.instant.prototype.tostring
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Instant(0n);
const result1 = instance.toString({ timeZone: "UTC" });
@ -14,3 +32,6 @@ assert.sameValue(result1.substr(-6), "+00:00", "Time zone created from string 'U
const result2 = instance.toString({ timeZone: "-01:30" });
assert.sameValue(result2.substr(-6), "-01:30", "Time zone created from string '-01:30'");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,12 +4,33 @@
/*---
esid: sec-temporal.instant.prototype.tozoneddatetime
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Instant(0n);
["UTC", "+01:30"].forEach((timeZone) => {
const result = instance.toZonedDateTime({ timeZone, calendar: "iso8601" });
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,12 +4,33 @@
/*---
esid: sec-temporal.instant.prototype.tozoneddatetimeiso
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.Instant(0n);
["UTC", "+01:30"].forEach((timeZone) => {
const result = instance.toZonedDateTimeISO(timeZone);
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.now.plaindate
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
// The following are all valid strings so should not throw:
["UTC", "+01:00"].forEach((timeZone) => {
Temporal.Now.plainDate("iso8601", timeZone);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.now.plaindateiso
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
// The following are all valid strings so should not throw:
["UTC", "+01:00"].forEach((timeZone) => {
Temporal.Now.plainDateISO(timeZone);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.now.plaindatetime
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
// The following are all valid strings so should not throw:
["UTC", "+01:00"].forEach((timeZone) => {
Temporal.Now.plainDateTime("iso8601", timeZone);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.now.plaindatetimeiso
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
// The following are all valid strings so should not throw:
["UTC", "+01:00"].forEach((timeZone) => {
Temporal.Now.plainDateTimeISO(timeZone);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.now.plaintimeiso
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
// The following are all valid strings so should not throw:
["UTC", "+01:00"].forEach((timeZone) => {
Temporal.Now.plainTimeISO(timeZone);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,10 +4,31 @@
/*---
esid: sec-temporal.now.zoneddatetime
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
["UTC", "+01:30"].forEach((timeZone) => {
const result = Temporal.Now.zonedDateTime("iso8601", timeZone);
assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,10 +4,31 @@
/*---
esid: sec-temporal.now.zoneddatetimeiso
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
["UTC", "+01:30"].forEach((timeZone) => {
const result = Temporal.Now.zonedDateTimeISO(timeZone);
assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,12 +4,33 @@
/*---
esid: sec-temporal.plaindate.prototype.tozoneddatetime
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.PlainDate(2000, 5, 2);
["UTC", "+01:30"].forEach((timeZone) => {
const result = instance.toZonedDateTime(timeZone);
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,12 +4,33 @@
/*---
esid: sec-temporal.plaindatetime.prototype.tozoneddatetime
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.PlainDateTime(2000, 5, 2);
["UTC", "+01:30"].forEach((timeZone) => {
const result = instance.toZonedDateTime(timeZone);
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,12 +4,33 @@
/*---
esid: sec-temporal.plaintime.prototype.tozoneddatetime
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.PlainTime();
["UTC", "+01:30"].forEach((timeZone) => {
const result = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone });
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,10 +4,31 @@
/*---
esid: sec-temporal.timezone.from
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
["UTC", "+01:30"].forEach((timeZone) => {
const result = Temporal.TimeZone.from(timeZone);
assert.sameValue(result.id, timeZone, `Time zone created from string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,9 +4,27 @@
/*---
esid: sec-temporal.zoneddatetime.compare
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
["UTC", "+01:30"].forEach((timeZone) => {
const epoch = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone(timeZone));
@ -14,3 +32,6 @@ features: [Temporal]
Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, epoch);
Temporal.ZonedDateTime.compare(epoch, { year: 2020, month: 5, day: 2, timeZone });
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,10 +4,31 @@
/*---
esid: sec-temporal.zoneddatetime.from
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
["UTC", "+01:30"].forEach((timeZone) => {
const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone });
assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.add
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.add(new Temporal.Duration(1));
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.day
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.day;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.dayofweek
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.dayOfWeek;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.dayofyear
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.dayOfYear;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.daysinmonth
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.daysInMonth;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.daysinweek
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.daysInWeek;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.daysinyear
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.daysInYear;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.zoneddatetime.prototype.equals
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance1 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC"));
assert(instance1.equals({ year: 1970, month: 1, day: 1, timeZone: "UTC" }), "Time zone created from string 'UTC'");
const instance2 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("-01:30"));
assert(instance2.equals({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }), "Time zone created from string '-01:30'");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.equals
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id");
Object.defineProperty(Temporal.TimeZone.prototype, "id", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("id should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.equals(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"));
Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal);

View File

@ -0,0 +1,25 @@
// 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.getisofields
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.getISOFields();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.hour
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.hour;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.inleapyear
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.inLeapYear;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.microsecond
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.microsecond;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.millisecond
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.millisecond;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.minute
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.minute;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.month
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.month;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.monthcode
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.monthCode;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.monthsinyear
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.monthsInYear;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.nanosecond
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.nanosecond;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.offset
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.offset;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.offsetnanoseconds
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.offsetNanoseconds;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.round
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.round("day");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.second
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.second;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.zoneddatetime.prototype.since
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance1 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC"));
assert(instance1.since({ year: 1970, month: 1, day: 1, timeZone: "UTC" }).blank, "Time zone created from string 'UTC'");
const instance2 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("-01:30"));
assert(instance2.since({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }).blank, "Time zone created from string '-01:30'");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.since
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.since(new Temporal.ZonedDateTime(0n, "UTC"));
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.startofday
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.startOfDay();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.subtract
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.subtract(new Temporal.Duration(1));
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.timezoneid
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id");
Object.defineProperty(Temporal.TimeZone.prototype, "id", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("id should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.timeZoneId;
Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal);

View File

@ -0,0 +1,34 @@
// 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: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id");
Object.defineProperty(Temporal.TimeZone.prototype, "id", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("id should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toJSON();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal);

View File

@ -0,0 +1,34 @@
// 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.tolocalestring
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id");
Object.defineProperty(Temporal.TimeZone.prototype, "id", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("id should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toLocaleString();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal);

View File

@ -0,0 +1,25 @@
// 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.toplaindate
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toPlainDate();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.toplaindatetime
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toPlainDateTime();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.toplainmonthday
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toPlainMonthDay();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.toplaintime
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toPlainTime();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.toplainyearmonth
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toPlainYearMonth();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.tostring
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id");
Object.defineProperty(Temporal.TimeZone.prototype, "id", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("id should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.toString();
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal);

View File

@ -4,11 +4,32 @@
/*---
esid: sec-temporal.zoneddatetime.prototype.until
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance1 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC"));
assert(instance1.until({ year: 1970, month: 1, day: 1, timeZone: "UTC" }).blank, "Time zone created from string 'UTC'");
const instance2 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("-01:30"));
assert(instance2.until({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }).blank, "Time zone created from string '-01:30'");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.until
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.until(new Temporal.ZonedDateTime(1_100_000_000_000_000_000n, "UTC"));
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.weekofyear
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.weekOfYear;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.with
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.with({ year: 2001 });
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.withplaindate
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.withPlainDate(new Temporal.PlainDate(2001, 6, 13));
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,34 @@
// 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.withplaintime
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.withPlainTime(new Temporal.PlainTime(12, 34, 56));
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.withtimezone
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id");
Object.defineProperty(Temporal.TimeZone.prototype, "id", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("id should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.withTimeZone("+01:00");
Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal);

View File

@ -4,12 +4,33 @@
/*---
esid: sec-temporal.zoneddatetime.prototype.withtimezone
description: Time zone IDs are valid input for a time zone
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
},
});
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(0n, "UTC");
["UTC", "+01:30"].forEach((timeZone) => {
const result = instance.withTimeZone(timeZone);
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
});
Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.year
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.year;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -0,0 +1,25 @@
// 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.yearofweek
description: >
Calling the method on an instance constructed with a builtin time zone causes
no observable lookups or calls to time zone methods.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
},
});
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
instance.yearOfWeek;
Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);

View File

@ -1,49 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-datetime-format-functions
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [Temporal]
---*/
const formatter = new Intl.DateTimeFormat(undefined, { calendar: "iso8601" });
const date = new Temporal.PlainDate(2021, 8, 4);
const datetime = new Temporal.PlainDateTime(2021, 8, 4, 0, 30, 45, 123, 456, 789);
const monthDay = new Temporal.PlainMonthDay(8, 4);
const time = new Temporal.PlainTime(0, 30, 45, 123, 456, 789);
const month = new Temporal.PlainYearMonth(2021, 8);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => formatter.format(date),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDate case)"
);
assert.throws(
TypeError,
() => formatter.format(datetime),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDateTime case)"
);
assert.throws(
TypeError,
() => formatter.format(monthDay),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainMonthDay case)"
);
assert.throws(
TypeError,
() => formatter.format(time),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainTime case)"
);
assert.throws(
TypeError,
() => formatter.format(month),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainYearMonth case)"
);
});

View File

@ -1,54 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.datetimeformat.prototype.formatRange
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [Temporal]
---*/
const formatter = new Intl.DateTimeFormat(undefined, { calendar: "iso8601" });
const date1 = new Temporal.PlainDate(2021, 8, 4);
const date2 = new Temporal.PlainDate(2021, 9, 4);
const datetime1 = new Temporal.PlainDateTime(2021, 8, 4, 0, 30, 45, 123, 456, 789);
const datetime2 = new Temporal.PlainDateTime(2021, 9, 4, 0, 30, 45, 123, 456, 789);
const monthDay1 = new Temporal.PlainMonthDay(8, 4);
const monthDay2 = new Temporal.PlainMonthDay(9, 4);
const time1 = new Temporal.PlainTime(0, 30, 45, 123, 456, 789);
const time2 = new Temporal.PlainTime(1, 30, 45, 123, 456, 789);
const month1 = new Temporal.PlainYearMonth(2021, 8);
const month2 = new Temporal.PlainYearMonth(2022, 8);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => formatter.formatRange(date1, date2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDate case)"
);
assert.throws(
TypeError,
() => formatter.formatRange(datetime1, datetime2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDateTime case)"
);
assert.throws(
TypeError,
() => formatter.formatRange(monthDay1, monthDay2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainMonthDay case)"
);
assert.throws(
TypeError,
() => formatter.formatRange(time1, time2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainTime case)"
);
assert.throws(
TypeError,
() => formatter.formatRange(month1, month2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainYearMonth case)"
);
});

View File

@ -1,54 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.formatRangeToParts
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [Temporal]
---*/
const formatter = new Intl.DateTimeFormat(undefined, { calendar: "iso8601" });
const date1 = new Temporal.PlainDate(2021, 8, 4);
const date2 = new Temporal.PlainDate(2021, 9, 4);
const datetime1 = new Temporal.PlainDateTime(2021, 8, 4, 0, 30, 45, 123, 456, 789);
const datetime2 = new Temporal.PlainDateTime(2021, 9, 4, 0, 30, 45, 123, 456, 789);
const monthDay1 = new Temporal.PlainMonthDay(8, 4);
const monthDay2 = new Temporal.PlainMonthDay(9, 4);
const time1 = new Temporal.PlainTime(0, 30, 45, 123, 456, 789);
const time2 = new Temporal.PlainTime(1, 30, 45, 123, 456, 789);
const month1 = new Temporal.PlainYearMonth(2021, 8);
const month2 = new Temporal.PlainYearMonth(2022, 8);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => formatter.formatRangeToParts(date1, date2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDate case)"
);
assert.throws(
TypeError,
() => formatter.formatRangeToParts(datetime1, datetime2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDateTime case)"
);
assert.throws(
TypeError,
() => formatter.formatRangeToParts(monthDay1, monthDay2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainMonthDay case)"
);
assert.throws(
TypeError,
() => formatter.formatRangeToParts(time1, time2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainTime case)"
);
assert.throws(
TypeError,
() => formatter.formatRangeToParts(month1, month2),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainYearMonth case)"
);
});

View File

@ -1,49 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.formatToParts
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [Temporal]
---*/
const formatter = new Intl.DateTimeFormat(undefined, { calendar: "iso8601" });
const date = new Temporal.PlainDate(2021, 8, 4);
const datetime = new Temporal.PlainDateTime(2021, 8, 4, 0, 30, 45, 123, 456, 789);
const monthDay = new Temporal.PlainMonthDay(8, 4);
const time = new Temporal.PlainTime(0, 30, 45, 123, 456, 789);
const month = new Temporal.PlainYearMonth(2021, 8);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => formatter.formatToParts(date),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDate case)"
);
assert.throws(
TypeError,
() => formatter.formatToParts(datetime),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainDateTime case)"
);
assert.throws(
TypeError,
() => formatter.formatToParts(monthDay),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainMonthDay case)"
);
assert.throws(
TypeError,
() => formatter.formatToParts(time),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainTime case)"
);
assert.throws(
TypeError,
() => formatter.formatToParts(month),
"Uncallable getOffsetNanosecondsFor should throw TypeError (PlainYearMonth case)"
);
});

View File

@ -12,4 +12,5 @@ const tz = Temporal.Now.timeZoneId();
assert(zdt instanceof Temporal.ZonedDateTime);
assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string");
assert.sameValue(zdt.calendarId, "gregory");
assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string");
assert.sameValue(zdt.timeZoneId, tz);

View File

@ -11,4 +11,5 @@ const zdt = Temporal.Now.zonedDateTime("gregory", "America/Los_Angeles");
assert(zdt instanceof Temporal.ZonedDateTime);
assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string");
assert.sameValue(zdt.calendarId, "gregory");
assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string");
assert.sameValue(zdt.timeZoneId, "America/Los_Angeles");

View File

@ -11,4 +11,5 @@ const zdt = Temporal.Now.zonedDateTimeISO("America/Los_Angeles");
assert(zdt instanceof Temporal.ZonedDateTime);
assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string");
assert.sameValue(zdt.calendarId, "iso8601");
assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string");
assert.sameValue(zdt.timeZoneId, "America/Los_Angeles");

View File

@ -1,22 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.tolocalestring
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
const instance = new Temporal.PlainDate(2000, 5, 2);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => instance.toLocaleString(),
`Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
);
});

View File

@ -1,22 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.tolocalestring
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => instance.toLocaleString(),
`Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
);
});

View File

@ -1,22 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plainmonthday.prototype.tolocalestring
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
const instance = new Temporal.PlainMonthDay(5, 2);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => instance.toLocaleString(undefined, { calendar: "iso8601" }),
`Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
);
});

View File

@ -1,22 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaintime.prototype.tolocalestring
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => instance.toLocaleString(),
`Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
);
});

View File

@ -1,22 +0,0 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plainyearmonth.prototype.tolocalestring
description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
const instance = new Temporal.PlainYearMonth(2000, 5);
Temporal.TimeZone.prototype.getPossibleInstantsFor = function () {
return [];
};
[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => {
Temporal.TimeZone.prototype.getOffsetNanosecondsFor = notCallable;
assert.throws(
TypeError,
() => instance.toLocaleString(undefined, { calendar: "iso8601" }),
`Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
);
});