Temporal's getTimeZoneTransition method returns moment without offset transition
Categories
(Core :: JavaScript: Standard Library, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox141 | --- | fixed |
People
(Reporter: fabon, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Steps to reproduce:
for (const timeZone of Intl.supportedValuesOf("timeZone")) {
const start = Temporal.PlainDate.from('1800-01-01').toZonedDateTime(timeZone);
const end = Temporal.Now.plainDateISO().add({ years: 5 }).toZonedDateTime(timeZone);
let current = start;
while (true) {
const next = current.getTimeZoneTransition('next');
if (next === null || Temporal.ZonedDateTime.compare(next, end) > 0) {
break;
}
if (current.offsetNanoseconds === next.offsetNanoseconds) {
// the returned moment doesn't correspond to a UTC offset change
console.log(next.subtract({ seconds: 1 }), next);
}
current = next;
}
}
Actual results:
hundreds of ZonedDateTime
are logged in console like below:
Temporal.ZonedDateTime 1977-10-20T23:59:59+01:00[Africa/Algiers] Temporal.ZonedDateTime 1977-10-21T00:00:00+01:00[Africa/Algiers]
Expected results:
no log on console
I didn't investigate all cases, but it seems that some cases correspond to the DST switch without offset transition, which getTimeZoneTransition
shouldn't return (if I understand the spec correctly).
https://tc39.es/proposal-temporal/#sec-temporal-getnamedtimezonenexttransition
A transition is a point in time where the UTC offset of a time zone changes, for example when Daylight Saving Time starts or stops. The returned value t represents the first nanosecond where the new UTC offset is used in this time zone, not the last nanosecond where the previous UTC offset is used.
Assignee | ||
Comment 2•3 months ago
|
||
Good question! I've filed https://github.com/tc39/proposal-temporal/issues/3105 to make this case more explicit in the Temporal spec.
Assignee | ||
Comment 3•3 months ago
•
|
||
.
Updated•3 months ago
|
Now the spec clarify what 'transition' is, and also there is a test case for this in test262.
https://github.com/tc39/proposal-temporal/pull/3108
https://github.com/tc39/test262/pull/4466
Assignee | ||
Comment 5•2 months ago
|
||
ICU4C returns transitions for all time zone rule changes, even if the effective
time zone offset didn't change. Temporal wants us to ignore these transitions.
Updated•2 months ago
|
Updated•24 days ago
|
Description
•