Temporal: Remove getCalendar and getTimeZone methods

Temporarily replace them with getISOFields().calendar/timeZone just to
keep the tests running until we remove Calendar and TimeZone objects
altogether.

See: tc39/proposal-temporal#2826
This commit is contained in:
Philip Chimento 2024-05-08 17:10:32 -07:00 committed by Ms2ger
parent 73f85aeeaf
commit 1213ab17ec
65 changed files with 33 additions and 906 deletions

View File

@ -17,9 +17,8 @@ Object.defineProperty(Temporal.Calendar, "from", {
const calendar = new Temporal.Calendar("iso8601"); const calendar = new Temporal.Calendar("iso8601");
const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar); const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar);
TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object"); TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object");
assert.sameValue(plainDateWithObject.getCalendar(), calendar); assert.sameValue(plainDateWithObject.getISOFields().calendar, calendar);
const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601"); const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601");
TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string"); TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string");
assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string"); assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string");
assert.notSameValue(plainDateWithString.getCalendar(), calendar);

View File

@ -17,5 +17,5 @@ features: [Temporal]
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => { TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => {
const result = Temporal.PlainDate.from(datetime); const result = Temporal.PlainDate.from(datetime);
TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2); TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2);
assert.sameValue(result.getCalendar(), calendar, "calendar result"); assert.sameValue(result.getISOFields().calendar, calendar, "calendar result");
}); });

View File

@ -19,7 +19,7 @@ TemporalHelpers.assertPlainDate(
); );
assert.sameValue( assert.sameValue(
result.getCalendar(), result.getISOFields().calendar,
calendar, calendar,
"Calendar is copied" "Calendar is copied"
); );

View File

@ -22,5 +22,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject }); const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
}); });

View File

@ -1,22 +0,0 @@
// 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.plaindate.prototype.getcalendar
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/
const getCalendar = Temporal.PlainDate.prototype.getCalendar;
assert.sameValue(typeof getCalendar, "function");
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
assert.throws(TypeError, () => getCalendar.call(null), "null");
assert.throws(TypeError, () => getCalendar.call(true), "true");
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCalendar.call(1), "1");
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDate), "Temporal.PlainDate");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDate.prototype), "Temporal.PlainDate.prototype");

View File

@ -1,33 +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.getcalendar
description: >
Tests that Temporal.PlainDate.prototype.getCalendar
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
---*/
assert.sameValue(Object.isExtensible(Temporal.PlainDate.prototype.getCalendar),
true, "Built-in objects must be extensible.");
assert.sameValue(Object.prototype.toString.call(Temporal.PlainDate.prototype.getCalendar),
"[object Function]", "Object.prototype.toString");
assert.sameValue(Object.getPrototypeOf(Temporal.PlainDate.prototype.getCalendar),
Function.prototype, "prototype");
assert.sameValue(Temporal.PlainDate.prototype.getCalendar.hasOwnProperty("prototype"),
false, "prototype property");

View File

@ -1,25 +0,0 @@
// 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.plaindate.prototype.getcalendar
description: Temporal.PlainDate.prototype.getCalendar.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainDate.prototype.getCalendar, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,23 +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.getcalendar
description: Temporal.PlainDate.prototype.getCalendar.name is "getCalendar".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainDate.prototype.getCalendar, "name", {
value: "getCalendar",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,21 +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.getcalendar
description: >
Temporal.PlainDate.prototype.getCalendar does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
---*/
assert.throws(TypeError, () => {
new Temporal.PlainDate.prototype.getCalendar();
}, "Calling as constructor");
assert.sameValue(isConstructor(Temporal.PlainDate.prototype.getCalendar), false,
"isConstructor(Temporal.PlainDate.prototype.getCalendar)");

View File

@ -1,21 +0,0 @@
// 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.plaindate.prototype.getcalendar
description: The "getCalendar" property of Temporal.PlainDate.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/
assert.sameValue(
typeof Temporal.PlainDate.prototype.getCalendar,
"function",
"`typeof PlainDate.prototype.getCalendar` is `function`"
);
verifyProperty(Temporal.PlainDate.prototype, "getCalendar", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -11,4 +11,4 @@ features: [Temporal]
const calendar = TemporalHelpers.calendarThrowEverything(); const calendar = TemporalHelpers.calendarThrowEverything();
const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar);
const result = plainDate.toPlainDateTime("11:30:23"); const result = plainDate.toPlainDateTime("11:30:23");
assert.sameValue(result.getCalendar(), calendar, "calendar"); assert.sameValue(result.getISOFields().calendar, calendar, "calendar");

View File

@ -16,4 +16,4 @@ const result = plainDate.toZonedDateTime({
}); });
assert.sameValue(result.epochNanoseconds, 957270600_000_000_000n); assert.sameValue(result.epochNanoseconds, 957270600_000_000_000n);
assert.sameValue(result.timeZoneId, "UTC"); assert.sameValue(result.timeZoneId, "UTC");
assert.sameValue(result.getCalendar(), calendar); assert.sameValue(result.getISOFields().calendar, calendar);

View File

@ -13,7 +13,7 @@ class CustomTimeZone extends Temporal.TimeZone {
super("UTC"); super("UTC");
} }
getPossibleInstantsFor(plainDateTime) { getPossibleInstantsFor(plainDateTime) {
assert.sameValue(plainDateTime.getCalendar(), calendar); assert.sameValue(plainDateTime.getISOFields().calendar, calendar);
return [new Temporal.Instant(987654321_000_000_000n)]; return [new Temporal.Instant(987654321_000_000_000n)];
} }
} }
@ -24,5 +24,5 @@ const result = plainDate.toZonedDateTime({
plainTime: { hour: 12, minute: 30 }, plainTime: { hour: 12, minute: 30 },
}); });
assert.sameValue(result.epochNanoseconds, 987654321_000_000_000n); assert.sameValue(result.epochNanoseconds, 987654321_000_000_000n);
assert.sameValue(result.getTimeZone(), timeZone); assert.sameValue(result.getISOFields().timeZone, timeZone);
assert.sameValue(result.getCalendar(), calendar); assert.sameValue(result.getISOFields().calendar, calendar);

View File

@ -14,15 +14,15 @@ const calendar = Temporal.Calendar.from("iso8601");
const objectResult = plainDate.withCalendar(calendar); const objectResult = plainDate.withCalendar(calendar);
assert.notSameValue(objectResult, plainDate, "object: new object"); assert.notSameValue(objectResult, plainDate, "object: new object");
TemporalHelpers.assertPlainDate(objectResult, 1976, 11, "M11", 18, "object"); TemporalHelpers.assertPlainDate(objectResult, 1976, 11, "M11", 18, "object");
assert.sameValue(objectResult.getCalendar(), calendar, "object: calendar"); assert.sameValue(objectResult.getISOFields().calendar, calendar, "object: calendar");
const stringResult = plainDate.withCalendar("iso8601"); const stringResult = plainDate.withCalendar("iso8601");
assert.notSameValue(stringResult, plainDate, "string: new object"); assert.notSameValue(stringResult, plainDate, "string: new object");
TemporalHelpers.assertPlainDate(stringResult, 1976, 11, "M11", 18, "string"); TemporalHelpers.assertPlainDate(stringResult, 1976, 11, "M11", 18, "string");
assert.sameValue(stringResult.getISOFields().calendar, "iso8601", "string: calendar slot stores a string"); assert.sameValue(stringResult.getISOFields().calendar, "iso8601", "string: calendar slot stores a string");
const originalCalendar = plainDate.getCalendar(); const originalCalendar = plainDate.getISOFields().calendar;
const sameResult = plainDate.withCalendar(originalCalendar); const sameResult = plainDate.withCalendar(originalCalendar);
assert.notSameValue(sameResult, plainDate, "original: new object"); assert.notSameValue(sameResult, plainDate, "original: new object");
TemporalHelpers.assertPlainDate(sameResult, 1976, 11, "M11", 18, "original"); TemporalHelpers.assertPlainDate(sameResult, 1976, 11, "M11", 18, "original");
assert.sameValue(sameResult.getCalendar(), originalCalendar, "original: calendar slot stores and object"); assert.sameValue(sameResult.getISOFields().calendar, originalCalendar, "original: calendar slot stores and object");

View File

@ -42,6 +42,6 @@ TemporalHelpers.checkSubclassingIgnored(
[customCalendar], [customCalendar],
(result) => { (result) => {
TemporalHelpers.assertPlainDate(result, 1900, 2, "M02", 5); TemporalHelpers.assertPlainDate(result, 1900, 2, "M02", 5);
assert.sameValue(result.getCalendar(), customCalendar, "calendar result"); assert.sameValue(result.getISOFields().calendar, customCalendar, "calendar result");
}, },
); );

View File

@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDateTime(datetime,
); );
assert.sameValue( assert.sameValue(
datetime.getCalendar(), datetime.getISOFields().calendar,
calendar, calendar,
"calendar supplied in constructor can be extracted and is unchanged" "calendar supplied in constructor can be extracted and is unchanged"
); );

View File

@ -17,5 +17,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => { TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => {
const result = Temporal.PlainDateTime.from(date); const result = Temporal.PlainDateTime.from(date);
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed"); TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed");
assert.sameValue(result.getCalendar(), calendar, "calendar result"); assert.sameValue(result.getISOFields().calendar, calendar, "calendar result");
}); });

View File

@ -22,5 +22,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject }); const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
}); });

View File

@ -1,22 +0,0 @@
// 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.plaindatetime.prototype.getcalendar
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/
const getCalendar = Temporal.PlainDateTime.prototype.getCalendar;
assert.sameValue(typeof getCalendar, "function");
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
assert.throws(TypeError, () => getCalendar.call(null), "null");
assert.throws(TypeError, () => getCalendar.call(true), "true");
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCalendar.call(1), "1");
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDateTime), "Temporal.PlainDateTime");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype");

View File

@ -1,33 +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.getcalendar
description: >
Tests that Temporal.PlainDateTime.prototype.getCalendar
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
---*/
assert.sameValue(Object.isExtensible(Temporal.PlainDateTime.prototype.getCalendar),
true, "Built-in objects must be extensible.");
assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.getCalendar),
"[object Function]", "Object.prototype.toString");
assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.getCalendar),
Function.prototype, "prototype");
assert.sameValue(Temporal.PlainDateTime.prototype.getCalendar.hasOwnProperty("prototype"),
false, "prototype property");

View File

@ -1,25 +0,0 @@
// 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.plaindatetime.prototype.getcalendar
description: Temporal.PlainDateTime.prototype.getCalendar.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainDateTime.prototype.getCalendar, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,23 +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.getcalendar
description: Temporal.PlainDateTime.prototype.getCalendar.name is "getCalendar".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainDateTime.prototype.getCalendar, "name", {
value: "getCalendar",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,21 +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.getcalendar
description: >
Temporal.PlainDateTime.prototype.getCalendar does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
---*/
assert.throws(TypeError, () => {
new Temporal.PlainDateTime.prototype.getCalendar();
}, "Calling as constructor");
assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.getCalendar), false,
"isConstructor(Temporal.PlainDateTime.prototype.getCalendar)");

View File

@ -1,21 +0,0 @@
// 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.plaindatetime.prototype.getcalendar
description: The "getCalendar" property of Temporal.PlainDateTime.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/
assert.sameValue(
typeof Temporal.PlainDateTime.prototype.getCalendar,
"function",
"`typeof PlainDateTime.prototype.getCalendar` is `function`"
);
verifyProperty(Temporal.PlainDateTime.prototype, "getCalendar", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -42,8 +42,8 @@ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
const result = dateTime.toZonedDateTime(timeZone, options); const result = dateTime.toZonedDateTime(timeZone, options);
assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds); assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds);
assert.sameValue(result.getTimeZone(), timeZone);
assert.compareArray(actual, expected); assert.compareArray(actual, expected);
assert.sameValue(result.getISOFields().timeZone, timeZone);
assert.sameValue(result.getISOFields().calendar, dateTime.getISOFields().calendar); assert.sameValue(result.getISOFields().calendar, dateTime.getISOFields().calendar);

View File

@ -19,4 +19,4 @@ TemporalHelpers.assertPlainDateTime(
"works" "works"
); );
assert.sameValue(result.getCalendar(), calendar, "underlying calendar is unchanged"); assert.sameValue(result.getISOFields().calendar, calendar, "underlying calendar is unchanged");

View File

@ -42,6 +42,6 @@ TemporalHelpers.checkSubclassingIgnored(
[customCalendar], [customCalendar],
(result) => { (result) => {
TemporalHelpers.assertPlainDateTime(result, 1900, 2, "M02", 5, 12, 34, 56, 987, 654, 321); TemporalHelpers.assertPlainDateTime(result, 1900, 2, "M02", 5, 12, 34, 56, 987, 654, 321);
assert.sameValue(result.getCalendar(), customCalendar, "calendar result"); assert.sameValue(result.getISOFields().calendar, customCalendar, "calendar result");
}, },
); );

View File

@ -22,5 +22,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject }); const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
}); });

View File

@ -1,22 +0,0 @@
// 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.plainmonthday.prototype.getcalendar
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/
const getCalendar = Temporal.PlainMonthDay.prototype.getCalendar;
assert.sameValue(typeof getCalendar, "function");
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
assert.throws(TypeError, () => getCalendar.call(null), "null");
assert.throws(TypeError, () => getCalendar.call(true), "true");
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCalendar.call(1), "1");
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainMonthDay), "Temporal.PlainMonthDay");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainMonthDay.prototype), "Temporal.PlainMonthDay.prototype");

View File

@ -1,33 +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.getcalendar
description: >
Tests that Temporal.PlainMonthDay.prototype.getCalendar
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
---*/
assert.sameValue(Object.isExtensible(Temporal.PlainMonthDay.prototype.getCalendar),
true, "Built-in objects must be extensible.");
assert.sameValue(Object.prototype.toString.call(Temporal.PlainMonthDay.prototype.getCalendar),
"[object Function]", "Object.prototype.toString");
assert.sameValue(Object.getPrototypeOf(Temporal.PlainMonthDay.prototype.getCalendar),
Function.prototype, "prototype");
assert.sameValue(Temporal.PlainMonthDay.prototype.getCalendar.hasOwnProperty("prototype"),
false, "prototype property");

View File

@ -1,25 +0,0 @@
// 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.plainmonthday.prototype.getcalendar
description: Temporal.PlainMonthDay.prototype.getCalendar.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainMonthDay.prototype.getCalendar, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,23 +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.getcalendar
description: Temporal.PlainMonthDay.prototype.getCalendar.name is "getCalendar".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainMonthDay.prototype.getCalendar, "name", {
value: "getCalendar",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,21 +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.getcalendar
description: >
Temporal.PlainMonthDay.prototype.getCalendar does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
---*/
assert.throws(TypeError, () => {
new Temporal.PlainMonthDay.prototype.getCalendar();
}, "Calling as constructor");
assert.sameValue(isConstructor(Temporal.PlainMonthDay.prototype.getCalendar), false,
"isConstructor(Temporal.PlainMonthDay.prototype.getCalendar)");

View File

@ -1,21 +0,0 @@
// 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.plainmonthday.prototype.getcalendar
description: The "getCalendar" property of Temporal.PlainMonthDay.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/
assert.sameValue(
typeof Temporal.PlainMonthDay.prototype.getCalendar,
"function",
"`typeof PlainMonthDay.prototype.getCalendar` is `function`"
);
verifyProperty(Temporal.PlainMonthDay.prototype, "getCalendar", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -22,5 +22,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject }); const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
}); });

View File

@ -1,22 +0,0 @@
// 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.plainyearmonth.prototype.getcalendar
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/
const getCalendar = Temporal.PlainYearMonth.prototype.getCalendar;
assert.sameValue(typeof getCalendar, "function");
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
assert.throws(TypeError, () => getCalendar.call(null), "null");
assert.throws(TypeError, () => getCalendar.call(true), "true");
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCalendar.call(1), "1");
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainYearMonth), "Temporal.PlainYearMonth");
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainYearMonth.prototype), "Temporal.PlainYearMonth.prototype");

View File

@ -1,33 +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.getcalendar
description: >
Tests that Temporal.PlainYearMonth.prototype.getCalendar
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
---*/
assert.sameValue(Object.isExtensible(Temporal.PlainYearMonth.prototype.getCalendar),
true, "Built-in objects must be extensible.");
assert.sameValue(Object.prototype.toString.call(Temporal.PlainYearMonth.prototype.getCalendar),
"[object Function]", "Object.prototype.toString");
assert.sameValue(Object.getPrototypeOf(Temporal.PlainYearMonth.prototype.getCalendar),
Function.prototype, "prototype");
assert.sameValue(Temporal.PlainYearMonth.prototype.getCalendar.hasOwnProperty("prototype"),
false, "prototype property");

View File

@ -1,25 +0,0 @@
// 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.plainyearmonth.prototype.getcalendar
description: Temporal.PlainYearMonth.prototype.getCalendar.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainYearMonth.prototype.getCalendar, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,23 +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.getcalendar
description: Temporal.PlainYearMonth.prototype.getCalendar.name is "getCalendar".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.PlainYearMonth.prototype.getCalendar, "name", {
value: "getCalendar",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,21 +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.getcalendar
description: >
Temporal.PlainYearMonth.prototype.getCalendar does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
---*/
assert.throws(TypeError, () => {
new Temporal.PlainYearMonth.prototype.getCalendar();
}, "Calling as constructor");
assert.sameValue(isConstructor(Temporal.PlainYearMonth.prototype.getCalendar), false,
"isConstructor(Temporal.PlainYearMonth.prototype.getCalendar)");

View File

@ -1,21 +0,0 @@
// 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.plainyearmonth.prototype.getcalendar
description: The "getCalendar" property of Temporal.PlainYearMonth.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/
assert.sameValue(
typeof Temporal.PlainYearMonth.prototype.getCalendar,
"function",
"`typeof PlainYearMonth.prototype.getCalendar` is `function`"
);
verifyProperty(Temporal.PlainYearMonth.prototype, "getCalendar", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -32,6 +32,6 @@ for (const thisValue of thisValues) {
const zdt = new Temporal.ZonedDateTime(0n, "UTC"); const zdt = new Temporal.ZonedDateTime(0n, "UTC");
const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt); const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt);
assert.notSameValue(fromZdt, zdt.getTimeZone(), "from() creates a new object from a string slot value"); assert.notSameValue(fromZdt, zdt.getISOFields().timeZone, "from() creates a new object from a string slot value");
assert.sameValue(fromZdt.id, "UTC"); assert.sameValue(fromZdt.id, "UTC");
} }

View File

@ -22,5 +22,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject }); const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
}); });

View File

@ -1,22 +0,0 @@
// 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.getcalendar
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/
const getCalendar = Temporal.ZonedDateTime.prototype.getCalendar;
assert.sameValue(typeof getCalendar, "function");
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
assert.throws(TypeError, () => getCalendar.call(null), "null");
assert.throws(TypeError, () => getCalendar.call(true), "true");
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
assert.throws(TypeError, () => getCalendar.call(1), "1");
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
assert.throws(TypeError, () => getCalendar.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime");
assert.throws(TypeError, () => getCalendar.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype");

View File

@ -1,33 +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.zoneddatetime.prototype.getcalendar
description: >
Tests that Temporal.ZonedDateTime.prototype.getCalendar
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
---*/
assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getCalendar),
true, "Built-in objects must be extensible.");
assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getCalendar),
"[object Function]", "Object.prototype.toString");
assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getCalendar),
Function.prototype, "prototype");
assert.sameValue(Temporal.ZonedDateTime.prototype.getCalendar.hasOwnProperty("prototype"),
false, "prototype property");

View File

@ -1,25 +0,0 @@
// 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.getcalendar
description: Temporal.ZonedDateTime.prototype.getCalendar.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.ZonedDateTime.prototype.getCalendar, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,23 +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.zoneddatetime.prototype.getcalendar
description: Temporal.ZonedDateTime.prototype.getCalendar.name is "getCalendar".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.ZonedDateTime.prototype.getCalendar, "name", {
value: "getCalendar",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,21 +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.zoneddatetime.prototype.getcalendar
description: >
Temporal.ZonedDateTime.prototype.getCalendar does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
---*/
assert.throws(TypeError, () => {
new Temporal.ZonedDateTime.prototype.getCalendar();
}, "Calling as constructor");
assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getCalendar), false,
"isConstructor(Temporal.ZonedDateTime.prototype.getCalendar)");

View File

@ -1,21 +0,0 @@
// 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.getcalendar
description: The "getCalendar" property of Temporal.ZonedDateTime.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/
assert.sameValue(
typeof Temporal.ZonedDateTime.prototype.getCalendar,
"function",
"`typeof ZonedDateTime.prototype.getCalendar` is `function`"
);
verifyProperty(Temporal.ZonedDateTime.prototype, "getCalendar", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -1,22 +0,0 @@
// 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.gettimezone
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/
const getTimeZone = Temporal.ZonedDateTime.prototype.getTimeZone;
assert.sameValue(typeof getTimeZone, "function");
assert.throws(TypeError, () => getTimeZone.call(undefined), "undefined");
assert.throws(TypeError, () => getTimeZone.call(null), "null");
assert.throws(TypeError, () => getTimeZone.call(true), "true");
assert.throws(TypeError, () => getTimeZone.call(""), "empty string");
assert.throws(TypeError, () => getTimeZone.call(Symbol()), "symbol");
assert.throws(TypeError, () => getTimeZone.call(1), "1");
assert.throws(TypeError, () => getTimeZone.call({}), "plain object");
assert.throws(TypeError, () => getTimeZone.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime");
assert.throws(TypeError, () => getTimeZone.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype");

View File

@ -1,33 +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.zoneddatetime.prototype.gettimezone
description: >
Tests that Temporal.ZonedDateTime.prototype.getTimeZone
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
---*/
assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getTimeZone),
true, "Built-in objects must be extensible.");
assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getTimeZone),
"[object Function]", "Object.prototype.toString");
assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getTimeZone),
Function.prototype, "prototype");
assert.sameValue(Temporal.ZonedDateTime.prototype.getTimeZone.hasOwnProperty("prototype"),
false, "prototype property");

View File

@ -1,25 +0,0 @@
// 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.gettimezone
description: Temporal.ZonedDateTime.prototype.getTimeZone.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZone, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,23 +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.zoneddatetime.prototype.gettimezone
description: Temporal.ZonedDateTime.prototype.getTimeZone.name is "getTimeZone".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
---*/
verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZone, "name", {
value: "getTimeZone",
writable: false,
enumerable: false,
configurable: true,
});

View File

@ -1,21 +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.zoneddatetime.prototype.gettimezone
description: >
Temporal.ZonedDateTime.prototype.getTimeZone does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
---*/
assert.throws(TypeError, () => {
new Temporal.ZonedDateTime.prototype.getTimeZone();
}, "Calling as constructor");
assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getTimeZone), false,
"isConstructor(Temporal.ZonedDateTime.prototype.getTimeZone)");

View File

@ -1,21 +0,0 @@
// 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.gettimezone
description: The "getTimeZone" property of Temporal.ZonedDateTime.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/
assert.sameValue(
typeof Temporal.ZonedDateTime.prototype.getTimeZone,
"function",
"`typeof ZonedDateTime.prototype.getTimeZone` is `function`"
);
verifyProperty(Temporal.ZonedDateTime.prototype, "getTimeZone", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -22,8 +22,6 @@ for (const [options, descr] of noopRoundingOperations) {
const result = instance.round(options); const result = instance.round(options);
assert.notSameValue(result, instance, "rounding result should be a new object"); assert.notSameValue(result, instance, "rounding result should be a new object");
assert.sameValue(result.epochNanoseconds, instance.epochNanoseconds, "instant should be unchanged"); assert.sameValue(result.epochNanoseconds, instance.epochNanoseconds, "instant should be unchanged");
assert.sameValue(result.getCalendar(), instance.getCalendar(), "calendar should be preserved");
assert.sameValue(result.getTimeZone(), instance.getTimeZone(), "time zone should be preserved");
} }
const notNoopRoundingOperations = [ const notNoopRoundingOperations = [

View File

@ -49,6 +49,6 @@ TemporalHelpers.checkSubclassingIgnored(
assert.sameValue(result.millisecond, 0, "millisecond result"); assert.sameValue(result.millisecond, 0, "millisecond result");
assert.sameValue(result.microsecond, 0, "microsecond result"); assert.sameValue(result.microsecond, 0, "microsecond result");
assert.sameValue(result.nanosecond, 10, "nanosecond result"); assert.sameValue(result.nanosecond, 10, "nanosecond result");
assert.sameValue(result.getCalendar(), customCalendar, "calendar result"); assert.sameValue(result.getISOFields().calendar, customCalendar, "calendar result");
}, },
); );

View File

@ -31,6 +31,6 @@ for (const thisValue of thisValues) {
const zdt = new Temporal.ZonedDateTime(0n, "Africa/Cairo"); const zdt = new Temporal.ZonedDateTime(0n, "Africa/Cairo");
const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt); const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt);
assert.notSameValue(fromZdt, zdt.getTimeZone(), "from() creates a new object for a string slot value"); assert.notSameValue(fromZdt, zdt.getISOFields().timeZone, "from() creates a new object for a string slot value");
assert.sameValue(fromZdt.id, "Africa/Cairo"); assert.sameValue(fromZdt.id, "Africa/Cairo");
} }

View File

@ -73,7 +73,7 @@ var monthday = new Temporal.PlainMonthDay(9, 15, calendar);
var zoned = new Temporal.ZonedDateTime(1568505600000000000n, "UTC", calendar); var zoned = new Temporal.ZonedDateTime(1568505600000000000n, "UTC", calendar);
var propDesc = { var propDesc = {
get() { get() {
return this.getCalendar().season(this); return this.getISOFields().calendar.season(this);
}, },
configurable: true configurable: true
}; };

View File

@ -97,13 +97,13 @@ var zoned = new Temporal.ZonedDateTime(1568505600000000000n, "UTC", calendar);
var propDesc = { var propDesc = {
century: { century: {
get() { get() {
return this.getCalendar().century(this); return this.getISOFields().calendar.century(this);
}, },
configurable: true configurable: true
}, },
centuryYear: { centuryYear: {
get() { get() {
return this.getCalendar().centuryYear(this); return this.getISOFields().calendar.centuryYear(this);
}, },
configurable: true configurable: true
} }

View File

@ -217,4 +217,4 @@ assert.sameValue(md2.monthCode, "M01");
var tz = Temporal.TimeZone.from("UTC"); var tz = Temporal.TimeZone.from("UTC");
var inst = Temporal.Instant.fromEpochMilliseconds(0); var inst = Temporal.Instant.fromEpochMilliseconds(0);
var dt = tz.getPlainDateTimeFor(inst, obj); var dt = tz.getPlainDateTimeFor(inst, obj);
assert.sameValue(dt.getCalendar(), obj); assert.sameValue(dt.getISOFields().calendar, obj);

View File

@ -153,4 +153,4 @@ assert.sameValue(md2.monthCode, "M02");
var tz = Temporal.TimeZone.from("UTC"); var tz = Temporal.TimeZone.from("UTC");
var instant = Temporal.Instant.fromEpochMilliseconds(0); var instant = Temporal.Instant.fromEpochMilliseconds(0);
var dt = tz.getPlainDateTimeFor(instant, obj); var dt = tz.getPlainDateTimeFor(instant, obj);
assert.sameValue(dt.getCalendar(), obj); assert.sameValue(dt.getISOFields().calendar, obj);

View File

@ -38,4 +38,4 @@ const fakeGregorian = {
yearOfWeek() {}, yearOfWeek() {},
}; };
var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz).withCalendar(fakeGregorian); var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz).withCalendar(fakeGregorian);
assert.sameValue(zdt.toPlainDate().getCalendar(), fakeGregorian); assert.sameValue(zdt.toPlainDate().getISOFields().calendar, fakeGregorian);

View File

@ -39,5 +39,5 @@ assert.sameValue(`${ zdt.withCalendar(cal) }`, "2019-11-18T15:23:30.123456789-08
var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00][u-ca=iso8601]"); var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00][u-ca=iso8601]");
var zdt2 = zdt.withCalendar(cal); var zdt2 = zdt.withCalendar(cal);
assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds); assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);
assert.sameValue(zdt2.getCalendar(), cal); assert.sameValue(zdt2.getISOFields().calendar, cal);
assert.sameValue(zdt2.timeZoneId, "+01:00"); assert.sameValue(zdt2.timeZoneId, "+01:00");

View File

@ -34,6 +34,6 @@ var fakeGregorian = {
var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]").withCalendar(fakeGregorian); var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]").withCalendar(fakeGregorian);
var zdt2 = zdt.withTimeZone("-08:00"); var zdt2 = zdt.withTimeZone("-08:00");
assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds); assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);
assert.sameValue(zdt2.getCalendar(), fakeGregorian); assert.sameValue(zdt2.getISOFields().calendar, fakeGregorian);
assert.sameValue(zdt2.timeZoneId, "-08:00"); assert.sameValue(zdt2.timeZoneId, "-08:00");
assert.notSameValue(`${ zdt.toPlainDateTime() }`, `${ zdt2.toPlainDateTime() }`); assert.notSameValue(`${ zdt.toPlainDateTime() }`, `${ zdt2.toPlainDateTime() }`);