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: CreateNormalizedDurationRecord is fallible #2779

Open
anba opened this issue Feb 20, 2024 · 2 comments
Open

DifferenceZonedDateTime: CreateNormalizedDurationRecord is fallible #2779

anba opened this issue Feb 20, 2024 · 2 comments

Comments

@anba
Copy link
Contributor

anba commented Feb 20, 2024

DifferenceZonedDateTime, step 11:

Return ! CreateNormalizedDurationRecord(dateDifference.[[Years]], dateDifference.[[Months]], dateDifference.[[Weeks]], result.[[Days]], result.[[Remainder]]).

The CreateNormalizedDurationRecord call is fallible. Test case:

const oneDay = BigInt(Temporal.Duration.from("P1D").total("nanoseconds"));

let cal = new class extends Temporal.Calendar {
  dateUntil(one, two, options) {
    return super.dateUntil(one, two, options).negated();
  }
}("iso8601");

let zdt1 = new Temporal.ZonedDateTime(0n, "UTC", cal);
let zdt2 = new Temporal.ZonedDateTime(50n * oneDay, "UTC", cal);

zdt1.until(zdt2, {
  largestUnit: "weeks",
});
@ptomato
Copy link
Collaborator

ptomato commented Feb 20, 2024

Thanks for figuring this out. Have you looked at #2760 yet? This may be obsolete once it lands.

@anba
Copy link
Contributor Author

anba commented Feb 23, 2024

Have you looked at #2760 yet? This may be obsolete once it lands.

No, I haven't yet looked at that PR.

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