Skip to content

Commit 30f8575

Browse files
committed
Editorial: Fix type assertion in TotalRelativeDuration
NudgeToCalendarUnit accepts a sign of -1 or 1, not 0, but it was possible for 0 to be passed in TotalRelativeDuration, which would fail a type assertion in the spec. However, 0 can just be treated as 1 for the purposes of NudgeToCalendarUnit. We already do the same thing in RoundRelativeDuration. (An alternative would be to add a fast path when the sign is 0, to just return a total of 0 directly. This would also be an unobservable editorial change.) Closes: #3131
1 parent c093099 commit 30f8575

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spec/duration.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@ <h1>
18531853
</dl>
18541854
<emu-alg>
18551855
1. If IsCalendarUnit(_unit_) is *true*, or _timeZone_ is not ~unset~ and _unit_ is ~day~, then
1856-
1. Let _sign_ be InternalDurationSign(_duration_).
1856+
1. If InternalDurationSign(_duration_) < 0, let _sign_ be -1; else let _sign_ be 1.
18571857
1. Let _record_ be ? NudgeToCalendarUnit(_sign_, _duration_, _destEpochNs_, _isoDateTime_, _timeZone_, _calendar_, 1, _unit_, ~trunc~).
18581858
1. Return _record_.[[Total]].
18591859
1. Let _timeDuration_ be ! Add24HourDaysToTimeDuration(_duration_.[[Time]], _duration_.[[Date]].[[Days]]).

0 commit comments

Comments
 (0)