-
Notifications
You must be signed in to change notification settings - Fork 157
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
Duration rounding throws an error #2919
Comments
This is a regression from #2884. So while the bad news is that we may have inadvertently introduced a bug, the good news is that there wasn't TC39 consensus on the buggy behaviour, so we can just make it work again without having to go to plenary. I'll investigate whether the best fix is a revert or something else, because there is definitely some stuff from #2884 that we should keep. |
Temporal.PlainDate.from("2023-05-31").until("2024-04-30", {largestUnit: "month"}).toString() returns
If DifferenceISODateTime had returned |
We probably just need to relax the assertions. See #2924 |
This test comes from a [bug report to Temporal]. We assert the result we get, and this also matches what Temporal does. But it does seem wrong to me IMO. We defer fixing it for now and leave it be to be consistent with Temporal. [bug report to Temporal]: tc39/proposal-temporal#2919
This test comes from a [bug report to Temporal]. We assert the result we get, and this also matches what Temporal does. But it does seem wrong to me IMO. We defer fixing it for now and leave it be to be consistent with Temporal. [bug report to Temporal]: tc39/proposal-temporal#2919
No, we can't just relax these range checks, because they ensure that Edit: I didn't see that you also propose to change That still leaves the question unanswered if |
Hi @anba, apologies for the narrow response. In the last champions meeting I was tasked with figuring out why the reference implementation throws an error while fullcalendar's temporal-polyfill does not. To add more context: the intermediate Given the mechanics of both |
@ptomato, I was wondering if you could help out with this. The question is whether having proposal-temporal/polyfill/lib/ecmascript.mjs Lines 3895 to 3920 in 3b47598
To my eyes, the computation of I am a bit confused about what the |
Hey @ptomato, any feedback on this? |
@arshaw Sorry about dropping the ball on this. ApplyUnsignedRoundingMode is written a bit differently in ECMA-402 than it is implemented in code. That's because I tried to find a way that would work for rounding bigints as well as FP numbers. The code const cmp = numerator.add(numerator).abs().subtract(denominator.abs()).sign();
if (cmp < 0) return r1;
if (cmp > 0) return r2; is intended to have the same effect as the spec steps When I wonder if it'd be simpler to leave ApplyUnsignedRoundingMode unchanged and instead treat |
@ptomato, thank you for that explanation. All understood. I've updated the PR to special-case |
…undingMode Closes: tc39#2919
See tc39/proposal-temporal#2919; this adds test coverage that would have caught an unintentional normative change.
See tc39/proposal-temporal#2919; this adds test coverage that would have caught an unintentional normative change.
…undingMode Closes: tc39#2919
I haven't checked if this also appears in the spec, but the polyfill at least throws a RangeError when it should not:
The text was updated successfully, but these errors were encountered: