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

Open
anba opened this issue Apr 18, 2024 · 0 comments
Open

DifferenceZonedDateTime: CreateTemporalDateTime is fallible #2824

anba opened this issue Apr 18, 2024 · 0 comments

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());
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

1 participant