Skip to content

Commit

Permalink
Editorial: Special case to avoid failing assertion in ApplyUnsignedRo…
Browse files Browse the repository at this point in the history
…undingMode

Closes: tc39#2919
  • Loading branch information
ptomato committed Aug 14, 2024
1 parent 8c6763e commit d8f28b0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1878,20 +1878,23 @@ <h1>
1. Let _endInstant_ be ? GetInstantFor(_timeZoneRec_, _endDateTime_, *"compatible"*).
1. Let _endEpochNs_ be _endInstant_.[[Nanoseconds]].
1. If _sign_ is 1, then
1. If _startEpochNs_ &gt; _destEpochNs_ or _destEpochNs_ _endEpochNs_, throw a *RangeError* exception.
1. Assert: _startEpochNs__destEpochNs_ &lt; _endEpochNs_.
1. If _startEpochNs_ &gt; _destEpochNs_ or _destEpochNs_ &gt; _endEpochNs_, throw a *RangeError* exception.
1. Assert: _startEpochNs__destEpochNs_ _endEpochNs_.
1. Else,
1. If _endEpochNs_ _destEpochNs_ or _destEpochNs_ &gt; _startEpochNs_, throw a *RangeError* exception.
1. Assert: _endEpochNs_ &lt; _destEpochNs__startEpochNs_.
1. If _endEpochNs_ &gt; _destEpochNs_ or _destEpochNs_ &gt; _startEpochNs_, throw a *RangeError* exception.
1. Assert: _endEpochNs_ _destEpochNs__startEpochNs_.
1. Assert: _startEpochNs__endEpochNs_.
1. Let _progress_ be (_destEpochNs_ - _startEpochNs_) / (_endEpochNs_ - _startEpochNs_).
1. Let _total_ be _r1_ + _progress_ × _increment_ × _sign_.
1. NOTE: The above two steps cannot be implemented directly using floating-point arithmetic. This division can be implemented as if constructing Normalized Time Duration Records for the denominator and numerator of _total_ and performing one division operation with a floating-point result.
1. Assert: 0 ≤ _progress_ &lt; 1.
1. Assert: 0 ≤ _progress_ 1.
1. If _sign_ &lt; 0, let _isNegative_ be ~negative~; else let _isNegative_ be ~positive~.
1. Let _unsignedRoundingMode_ be GetUnsignedRoundingMode(_roundingMode_, _isNegative_).
1. Assert: abs(_r1_) ≤ abs(_total_) &lt; abs(_r2_).
1. Let _roundedUnit_ be ApplyUnsignedRoundingMode(abs(_total_), abs(_r1_), abs(_r2_), _unsignedRoundingMode_).
1. Assert: abs(_r1_) ≤ abs(_total_) ≤ abs(_r2_).
1. If _progress_ = 1, then
1. Let _roundedUnit_ be abs(_r2_).
1. Else,
1. Let _roundedUnit_ be ApplyUnsignedRoundingMode(abs(_total_), abs(_r1_), abs(_r2_), _unsignedRoundingMode_).
1. If _roundedUnit_ is abs(_r2_), then
1. Let _didExpandCalendarUnit_ be *true*.
1. Let _resultDuration_ be _endDuration_.
Expand Down

0 comments on commit d8f28b0

Please sign in to comment.