-
Notifications
You must be signed in to change notification settings - Fork 156
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::total
incorrect result with DST
#2817
Comments
OK, I buy this explanation. The correct answer seems like 1+1/23 and that is also what results from the algorithm we are discussing in #2792. I still need to look at a few other cases though. |
ptomato
added a commit
that referenced
this issue
May 1, 2024
ptomato
added a commit
that referenced
this issue
May 2, 2024
ptomato
added a commit
that referenced
this issue
May 3, 2024
ptomato
added a commit
that referenced
this issue
May 3, 2024
ptomato
added a commit
that referenced
this issue
May 7, 2024
ptomato
added a commit
that referenced
this issue
May 7, 2024
These optimizations were developed by Adam Shaw: https://gist.github.com/arshaw/36d3152c21482bcb78ea2c69591b20e0 It does the same thing as previously, although fixes some incidental edge cases that Adam discovered. However, the algorithm is simpler to explain and to understand, and also makes fewer calls into user code. It uses three variations on a bounding technique for rounding: computing the upper and lower result, and checking which one is closer to the original duration, and 'nudging' the duration up or down accordingly. There is one variation for calendar units, one variation for rounding relative to a ZonedDateTime where smallestUnit is a time unit and largestUnit is a calendar unit, and one variation for time units. RoundDuration becomes a lot more simplified, any part of it that was complex is now split out into the new RoundRelativeDuration and BubbleRelativeDuration operations, and the three 'nudging' operations. The operations NormalizedTimeDurationToDays, BalanceTimeDurationRelative, BalanceDateDurationRelative, MoveRelativeDate, MoveRelativeZonedDateTime, and AdjustRoundedDurationDays are no longer needed. Their functionality is subsumed by the new operations. Closes: #2792 Closes: #2817
ptomato
added a commit
that referenced
this issue
May 10, 2024
These optimizations were developed by Adam Shaw: https://gist.github.com/arshaw/36d3152c21482bcb78ea2c69591b20e0 It does the same thing as previously, although fixes some incidental edge cases that Adam discovered. However, the algorithm is simpler to explain and to understand, and also makes fewer calls into user code. It uses three variations on a bounding technique for rounding: computing the upper and lower result, and checking which one is closer to the original duration, and 'nudging' the duration up or down accordingly. There is one variation for calendar units, one variation for rounding relative to a ZonedDateTime where smallestUnit is a time unit and largestUnit is a calendar unit, and one variation for time units. RoundDuration becomes a lot more simplified, any part of it that was complex is now split out into the new RoundRelativeDuration and BubbleRelativeDuration operations, and the three 'nudging' operations. The operations NormalizedTimeDurationToDays, BalanceTimeDurationRelative, BalanceDateDurationRelative, MoveRelativeDate, MoveRelativeZonedDateTime, and AdjustRoundedDurationDays are no longer needed. Their functionality is subsumed by the new operations. Closes: #2792 Closes: #2817
ptomato
added a commit
that referenced
this issue
May 13, 2024
These optimizations were developed by Adam Shaw: https://gist.github.com/arshaw/36d3152c21482bcb78ea2c69591b20e0 It does the same thing as previously, although fixes some incidental edge cases that Adam discovered. However, the algorithm is simpler to explain and to understand, and also makes fewer calls into user code. It uses three variations on a bounding technique for rounding: computing the upper and lower result, and checking which one is closer to the original duration, and 'nudging' the duration up or down accordingly. There is one variation for calendar units, one variation for rounding relative to a ZonedDateTime where smallestUnit is a time unit and largestUnit is a calendar unit, and one variation for time units. RoundDuration becomes a lot more simplified, any part of it that was complex is now split out into the new RoundRelativeDuration and BubbleRelativeDuration operations, and the three 'nudging' operations. The operations NormalizedTimeDurationToDays, BalanceTimeDurationRelative, BalanceDateDurationRelative, MoveRelativeDate, MoveRelativeZonedDateTime, and AdjustRoundedDurationDays are no longer needed. Their functionality is subsumed by the new operations. Closes: #2792 Closes: #2817
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Duration::total
is mishandling DST gaps with unit is 'day'I realized this when running this test failing for my polyfill. Portable recreation:
The problem is happening here:
proposal-temporal/polyfill/lib/ecmascript.mjs
Lines 3312 to 3319 in 1c9ddf5
I'd recommend reworking the
Duration::total()
system. This should happen while handling the reworks suggested in #2792.The text was updated successfully, but these errors were encountered: