mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 23:14:47 +02:00
Change Temporal.TimeZone compare semantics to use .id
Compare semantics for custom time zones that _don't_ extend Temporal.TimeZone (and therefore don't have the internal slot) use the value of the .id property, instead of calling toString(). Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
This commit is contained in:
parent
960070549b
commit
8c37094e1f
@ -1798,6 +1798,10 @@ var TemporalHelpers = {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return "Custom/Spring_Fall";
|
||||||
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return "Custom/Spring_Fall";
|
return "Custom/Spring_Fall";
|
||||||
}
|
}
|
||||||
@ -1818,7 +1822,9 @@ var TemporalHelpers = {
|
|||||||
*/
|
*/
|
||||||
timeZoneObserver(calls, objectName, methodOverrides = {}) {
|
timeZoneObserver(calls, objectName, methodOverrides = {}) {
|
||||||
const utc = new Temporal.TimeZone("UTC");
|
const utc = new Temporal.TimeZone("UTC");
|
||||||
const trackingMethods = {};
|
const trackingMethods = {
|
||||||
|
id: "UTC",
|
||||||
|
};
|
||||||
// Automatically generate the methods
|
// Automatically generate the methods
|
||||||
["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => {
|
["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => {
|
||||||
trackingMethods[methodName] = function (...args) {
|
trackingMethods[methodName] = function (...args) {
|
||||||
|
@ -58,12 +58,8 @@ const expected = [
|
|||||||
"get other.timeZone.getOffsetNanosecondsFor",
|
"get other.timeZone.getOffsetNanosecondsFor",
|
||||||
"call other.timeZone.getOffsetNanosecondsFor",
|
"call other.timeZone.getOffsetNanosecondsFor",
|
||||||
// TimeZoneEquals
|
// TimeZoneEquals
|
||||||
"get this.timeZone[Symbol.toPrimitive]",
|
"get this.timeZone.id",
|
||||||
"get this.timeZone.toString",
|
"get other.timeZone.id",
|
||||||
"call this.timeZone.toString",
|
|
||||||
"get other.timeZone[Symbol.toPrimitive]",
|
|
||||||
"get other.timeZone.toString",
|
|
||||||
"call other.timeZone.toString",
|
|
||||||
// CalendarEquals
|
// CalendarEquals
|
||||||
"get this.calendar.id",
|
"get this.calendar.id",
|
||||||
"get other.calendar.id",
|
"get other.calendar.id",
|
||||||
|
@ -125,12 +125,8 @@ actual.splice(0); // clear
|
|||||||
// Making largestUnit a calendar unit adds the following observable operations:
|
// Making largestUnit a calendar unit adds the following observable operations:
|
||||||
const expectedOpsForCalendarDifference = [
|
const expectedOpsForCalendarDifference = [
|
||||||
// TimeZoneEquals
|
// TimeZoneEquals
|
||||||
"get this.timeZone[Symbol.toPrimitive]",
|
"get this.timeZone.id",
|
||||||
"get this.timeZone.toString",
|
"get other.timeZone.id",
|
||||||
"call this.timeZone.toString",
|
|
||||||
"get other.timeZone[Symbol.toPrimitive]",
|
|
||||||
"get other.timeZone.toString",
|
|
||||||
"call other.timeZone.toString",
|
|
||||||
// DifferenceZonedDateTime
|
// DifferenceZonedDateTime
|
||||||
"get this.timeZone.getOffsetNanosecondsFor",
|
"get this.timeZone.getOffsetNanosecondsFor",
|
||||||
"call this.timeZone.getOffsetNanosecondsFor",
|
"call this.timeZone.getOffsetNanosecondsFor",
|
||||||
|
@ -31,9 +31,7 @@ const expected = [
|
|||||||
"call this.timeZone.getOffsetNanosecondsFor",
|
"call this.timeZone.getOffsetNanosecondsFor",
|
||||||
"get this.timeZone.getOffsetNanosecondsFor",
|
"get this.timeZone.getOffsetNanosecondsFor",
|
||||||
"call this.timeZone.getOffsetNanosecondsFor",
|
"call this.timeZone.getOffsetNanosecondsFor",
|
||||||
"get this.timeZone[Symbol.toPrimitive]",
|
"get this.timeZone.id",
|
||||||
"get this.timeZone.toString",
|
|
||||||
"call this.timeZone.toString",
|
|
||||||
"get this.calendar.id",
|
"get this.calendar.id",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
@ -79,9 +77,7 @@ const expectedForFractionalSecondDigits = [
|
|||||||
"call this.timeZone.getOffsetNanosecondsFor",
|
"call this.timeZone.getOffsetNanosecondsFor",
|
||||||
"get this.timeZone.getOffsetNanosecondsFor",
|
"get this.timeZone.getOffsetNanosecondsFor",
|
||||||
"call this.timeZone.getOffsetNanosecondsFor",
|
"call this.timeZone.getOffsetNanosecondsFor",
|
||||||
"get this.timeZone[Symbol.toPrimitive]",
|
"get this.timeZone.id",
|
||||||
"get this.timeZone.toString",
|
|
||||||
"call this.timeZone.toString",
|
|
||||||
"get this.calendar.id",
|
"get this.calendar.id",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ const tests = [
|
|||||||
["+01:00", "1970-01-01T02:01:01.987654321+01:00[+01:00]", "built-in offset"],
|
["+01:00", "1970-01-01T02:01:01.987654321+01:00[+01:00]", "built-in offset"],
|
||||||
[{
|
[{
|
||||||
getOffsetNanosecondsFor() { return 0; },
|
getOffsetNanosecondsFor() { return 0; },
|
||||||
toString() { return "Etc/Custom"; },
|
id: "Etc/Custom",
|
||||||
}, "1970-01-01T01:01:01.987654321+00:00[Etc/Custom]", "custom"],
|
}, "1970-01-01T01:01:01.987654321+00:00[Etc/Custom]", "custom"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ const tests = [
|
|||||||
["+01:00", "1970-01-01T02:01:01.987654321+01:00[!+01:00]", "built-in offset"],
|
["+01:00", "1970-01-01T02:01:01.987654321+01:00[!+01:00]", "built-in offset"],
|
||||||
[{
|
[{
|
||||||
getOffsetNanosecondsFor() { return 0; },
|
getOffsetNanosecondsFor() { return 0; },
|
||||||
toString() { return "Etc/Custom"; },
|
id: "Etc/Custom",
|
||||||
}, "1970-01-01T01:01:01.987654321+00:00[!Etc/Custom]", "custom"],
|
}, "1970-01-01T01:01:01.987654321+00:00[!Etc/Custom]", "custom"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -125,12 +125,8 @@ actual.splice(0); // clear
|
|||||||
// Making largestUnit a calendar unit adds the following observable operations:
|
// Making largestUnit a calendar unit adds the following observable operations:
|
||||||
const expectedOpsForCalendarDifference = [
|
const expectedOpsForCalendarDifference = [
|
||||||
// TimeZoneEquals
|
// TimeZoneEquals
|
||||||
"get this.timeZone[Symbol.toPrimitive]",
|
"get this.timeZone.id",
|
||||||
"get this.timeZone.toString",
|
"get other.timeZone.id",
|
||||||
"call this.timeZone.toString",
|
|
||||||
"get other.timeZone[Symbol.toPrimitive]",
|
|
||||||
"get other.timeZone.toString",
|
|
||||||
"call other.timeZone.toString",
|
|
||||||
// DifferenceZonedDateTime
|
// DifferenceZonedDateTime
|
||||||
"get this.timeZone.getOffsetNanosecondsFor",
|
"get this.timeZone.getOffsetNanosecondsFor",
|
||||||
"call this.timeZone.getOffsetNanosecondsFor",
|
"call this.timeZone.getOffsetNanosecondsFor",
|
||||||
|
@ -18,9 +18,7 @@ var obj = {
|
|||||||
var epochNs = MakeDate(dayNum, time);
|
var epochNs = MakeDate(dayNum, time);
|
||||||
return [new Temporal.Instant(epochNs)];
|
return [new Temporal.Instant(epochNs)];
|
||||||
},
|
},
|
||||||
toString() {
|
id: "Etc/Custom/UTC_Protocol",
|
||||||
return "Etc/Custom/UTC_Protocol";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
var inst = Temporal.Instant.fromEpochNanoseconds(0n);
|
var inst = Temporal.Instant.fromEpochNanoseconds(0n);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ assert.sameValue(zdt.toInstant().epochSeconds, Math.floor(Date.UTC(1976, 10, 18,
|
|||||||
assert.sameValue(zdt.toInstant().epochMilliseconds, Date.UTC(1976, 10, 18, 15, 23, 30, 123), "epochMilliseconds");
|
assert.sameValue(zdt.toInstant().epochMilliseconds, Date.UTC(1976, 10, 18, 15, 23, 30, 123), "epochMilliseconds");
|
||||||
|
|
||||||
// Temporal.ZonedDateTime for (1976, 11, 18, 15, 23, 30, 123, 456, 789)"
|
// Temporal.ZonedDateTime for (1976, 11, 18, 15, 23, 30, 123, 456, 789)"
|
||||||
var zdt = new Temporal.ZonedDateTime(epochNanos, new Temporal.TimeZone("UTC"));
|
var zdt = new Temporal.ZonedDateTime(epochNanos, "UTC");
|
||||||
// can be constructed
|
// can be constructed
|
||||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||||
assert.sameValue(typeof zdt, "object");
|
assert.sameValue(typeof zdt, "object");
|
||||||
@ -70,7 +70,7 @@ var fakeGregorian = {
|
|||||||
};
|
};
|
||||||
var fakeVienna = {
|
var fakeVienna = {
|
||||||
getOffsetNanosecondsFor() { return 3600_000_000_000; },
|
getOffsetNanosecondsFor() { return 3600_000_000_000; },
|
||||||
toString() { return "Europe/Vienna"; },
|
id: "Europe/Vienna",
|
||||||
}
|
}
|
||||||
var zdt = new Temporal.ZonedDateTime(epochNanos, fakeVienna, fakeGregorian);
|
var zdt = new Temporal.ZonedDateTime(epochNanos, fakeVienna, fakeGregorian);
|
||||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||||
|
@ -9,7 +9,7 @@ features: [Temporal]
|
|||||||
|
|
||||||
var tz = {
|
var tz = {
|
||||||
getPossibleInstantsFor(pdt) { return Temporal.TimeZone.from("-05:00").getPossibleInstantsFor(pdt); },
|
getPossibleInstantsFor(pdt) { return Temporal.TimeZone.from("-05:00").getPossibleInstantsFor(pdt); },
|
||||||
toString() { return "America/New_York"; },
|
id: "America/New_York",
|
||||||
};
|
};
|
||||||
var cal = {
|
var cal = {
|
||||||
dateFromFields(...args) { return Temporal.Calendar.from("iso8601").dateFromFields(...args); },
|
dateFromFields(...args) { return Temporal.Calendar.from("iso8601").dateFromFields(...args); },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user