Closed Bug 1962010 Opened 3 months ago Closed 1 month ago

Temporal's getTimeZoneTransition method returns moment without offset transition

Categories

(Core :: JavaScript: Standard Library, defect, P2)

defect

Tracking

()

RESOLVED FIXED
141 Branch
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.

Good question! I've filed https://github.com/tc39/proposal-temporal/issues/3105 to make this case more explicit in the Temporal spec.

Status: UNCONFIRMED → RESOLVED
Closed: 3 months ago
Resolution: --- → INVALID

.

Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Blocks: temporal
Severity: -- → S3
Priority: -- → P2

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

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.

Assignee: nobody → andrebargull
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/8270dfc2ffcd https://hg.mozilla.org/integration/autoland/rev/90129c1a89b3 Skip over time zone transition which don't change the time zone offset. r=spidermonkey-reviewers,dminor
Status: REOPENED → RESOLVED
Closed: 3 months ago1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch
QA Whiteboard: [qa-triage-done-c142/b141]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: