Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DifferenceZonedDateTime: CreateTemporalDateTime is fallible #2824

Closed
anba opened this issue Apr 18, 2024 · 1 comment
Closed

DifferenceZonedDateTime: CreateTemporalDateTime is fallible #2824

anba opened this issue Apr 18, 2024 · 1 comment

Comments

@anba
Copy link
Contributor

anba commented Apr 18, 2024

DifferenceZonedDateTime, step 12.b:

Let intermediateDateTime be ! CreateTemporalDateTime(intermediateDate.[[Year]], intermediateDate.[[Month]], intermediateDate.[[Day]], startDateTime.[[ISOHour]], startDateTime.[[ISOMinute]], startDateTime.[[ISOSecond]], startDateTime.[[ISOMillisecond]], startDateTime.[[ISOMicrosecond]], startDateTime.[[ISONanosecond]], calendarRec.[[Receiver]]).

This call is fallible. Test case:

const nsMaxInstant = 864n * 10n**19n;
const nsMinInstant = -nsMaxInstant;

const nsPerDay = 24*60*60*1000*1000*1000;

let tz = new class extends Temporal.TimeZone {
  getOffsetNanosecondsFor(instant) {
    if (instant.epochNanoseconds === nsMinInstant) {
      return 0;
    }
    return -nsPerDay + 1;
  }
}("UTC");

let zdt1 = new Temporal.ZonedDateTime(nsMinInstant, tz);
let zdt2 = new Temporal.ZonedDateTime(nsMinInstant + 1n, tz);

let d = zdt1.until(zdt2, {
  largestUnit: "days",
});

console.log(d.toString());
@ptomato
Copy link
Collaborator

ptomato commented Sep 6, 2024

This should have been fixed with #2925, creating the intermediate should no longer be fallible due to removing custom time zones. The intermediate date time could still be outside the representable range, but that will get caught by GetPossibleEpochNanoseconds.

@ptomato ptomato closed this as completed Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants