Skip to content

Commit

Permalink
Editorial: Assert AdjustDateDurationRecord in Duration.round()/total()
Browse files Browse the repository at this point in the history
This was a mistake in #2943. _targetTime_.[[Days]] cannot exceed the
original value of _duration_.[[Days]] here because its absolute value can
only be equal or smaller coming out of AddTime.
  • Loading branch information
ptomato committed Sep 24, 2024
1 parent 764b909 commit e97c2ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ <h1>Temporal.Duration.prototype.round ( _roundTo_ )</h1>
1. Let _targetTime_ be AddTime(0, 0, 0, 0, 0, 0, _normalizedDuration_.[[NormalizedTime]]).
1. Let _isoRelativeToDate_ be TemporalObjectToISODateRecord(_plainRelativeTo_).
1. Let _calendar_ be _plainRelativeTo_.[[Calendar]].
1. Let _dateDuration_ be ? AdjustDateDurationRecord(_normalizedDuration_.[[Date]], _targetTime_.[[Days]]).
1. Let _dateDuration_ be ! AdjustDateDurationRecord(_normalizedDuration_.[[Date]], _targetTime_.[[Days]]).
1. Let _targetDate_ be ? CalendarDateAdd(_calendar_, _isoRelativeToDate_, _dateDuration_, *"constrain"*).
1. Let _roundRecord_ be ? DifferencePlainDateTimeWithRounding(_isoRelativeToDate_.[[Year]], _isoRelativeToDate_.[[Month]], _isoRelativeToDate_.[[Day]], 0, 0, 0, 0, 0, 0, _targetDate_.[[Year]], _targetDate_.[[Month]], _targetDate_.[[Day]], _targetTime_.[[Hours]], _targetTime_.[[Minutes]], _targetTime_.[[Seconds]], _targetTime_.[[Milliseconds]], _targetTime_.[[Microseconds]], _targetTime_.[[Nanoseconds]], _calendar_, _largestUnit_, _roundingIncrement_, _smallestUnit_, _roundingMode_).
1. Return _roundRecord_.[[Duration]].
Expand Down Expand Up @@ -486,7 +486,7 @@ <h1>Temporal.Duration.prototype.total ( _totalOf_ )</h1>
1. Let _targetTime_ be AddTime(0, 0, 0, 0, 0, 0, _normalizedDuration_.[[NormalizedTime]]).
1. Let _isoRelativeToDate_ be TemporalObjectToISODateRecord(_plainRelativeTo_).
1. Let _calendar_ be _plainRelativeTo_.[[Calendar]].
1. Let _dateDuration_ be ? AdjustDateDurationRecord(_normalizedDuration_.[[Date]], _targetTime_.[[Days]]).
1. Let _dateDuration_ be ! AdjustDateDurationRecord(_normalizedDuration_.[[Date]], _targetTime_.[[Days]]).
1. Let _targetDate_ be ? CalendarDateAdd(_calendar_, _isoRelativeToDate_, _dateDuration_, *"constrain"*).
1. Let _roundRecord_ be ? DifferencePlainDateTimeWithRounding(_isoRelativeToDate_.[[Year]], _isoRelativeToDate_.[[Month]], _isoRelativeToDate_.[[Day]], 0, 0, 0, 0, 0, 0, _targetDate_.[[Year]], _targetDate_.[[Month]], _targetDate_.[[Day]], _targetTime_.[[Hour]], _targetTime_.[[Minute]], _targetTime_.[[Second]], _targetTime_.[[Millisecond]], _targetTime_.[[Microsecond]], _targetTime_.[[Nanosecond]], _calendar_, _unit_, 1, _unit_, *"trunc"*).
1. Else,
Expand Down

0 comments on commit e97c2ac

Please sign in to comment.