Comments (4)
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.
from proposal-temporal.
Temporal.PlainDate.from("2023-05-31").until("2024-04-30", {largestUnit: "month"}).toString()
returns "P10M30D"
, but used to return "P11M"
at some point. SpiderMonkey still uses the old definition of DifferenceISODate
, which is probably why it doesn't throw a RangeError for the round
call.
Temporal.Duration.prototype.round
calls DifferencePlainDateTimeWithRounding
with one = 2023-05-31
and two = 2024-04-30
. DifferenceISODateTime(one, two, largestUnit = "months")
returns P10M30D
. So RoundRelativeDuration
is called with duration = P10M30D
and increment = 1
. In NudgeToCalendarUnit
, r1 = 10
(months from P10M30D
) and r2 = 11
. Adding r2
months to the start date ("2023-05-31") returns the end date ("2024-04-30"), which leads to evaluating true
for destEpochNs ≥ endEpochNs
in NudgeToCalendarUnit, step 13.a.
If DifferenceISODateTime had returned "P11M"
instead of "P10M30D"
, then r1 = 11
and r2 = 12
, and everything would have worked correctly.
from proposal-temporal.
We probably just need to relax the assertions. See #2924
from proposal-temporal.
No, we can't just relax these range checks, because they ensure that ApplyUnsignedRoundingMode
can be called without hitting assertions within ApplyUnsignedRoundingMode
, specifically the Assert: r1 < x < r2.
step.
Edit: I didn't see that you also propose to change ApplyUnsignedRoundingMode
. I don't have enough time to check if ApplyUnsignedRoundingMode
can be changed to allow r1 ≤ x ≤ r2
instead of the current requirement r1 ≤ x < r2
.
That still leaves the question unanswered if Temporal.PlainDate.from("2023-05-31").until("2024-04-30", {largestUnit: "month"}).toString()
should return "P10M30D"
or "P11M"
. I'd prefer if this question is first answered before applying #2924.
from proposal-temporal.
Related Issues (20)
- AddDate: CreateTemporalDate is fallible
- does `ZonedDateTime.from` with `offset: reject` always throw when the datetime is in a DST transition gap? if so, is that intended?
- NudgeToCalendarUnit: Wrong roundedSign for (roundedUnit - total == 0)? HOT 1
- NudgeToDayOrTime: Incorrect assertion in step 1
- Polyfill: Buddhist, Ethiopic-Amete-Alem, Indian, Islamic, and Persian calendar return non-undefind era HOT 3
- CalendarFieldDescriptors: Require eraYear to be alway positive? HOT 8
- Polyfill: Allow alternate era codes
- RoundRelativeDuration: Disallow edge case in roundingIncrement within year/month HOT 5
- SystemDateTime, SystemZonedDateTime: "calendarLike" argument is always constant string "iso8601"
- Polyfill : undefined weekOfYear and yearOfWeek with calendarId = "islamic-civil" HOT 3
- Move AvailableCalendars from 402 into 262
- Implement calendar canonicalization to match 402
- ZonedDateTime.from() / .with() overflow option default HOT 1
- ZonedDateTime.startOfDay: is it guaranteed to be the first instant in a calendar day? HOT 17
- background on why there is only one Duration type? HOT 5
- ZonedDateTime.withPlainTime() Documentation HOT 1
- GetTemporalOverflowOption(options) looks redundant in 9.2.2 HOT 1
- calendarName to showCalendar rename? HOT 3
- GetRoundingIncrementOption: Call ToIntegerWithTruncation?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-temporal.