Skip to content

Commit

Permalink
Editorial: ToDateDurationRecordWithoutTime is infallible
Browse files Browse the repository at this point in the history
The input is an existing valid Temporal.Duration object, which cannot have
a total of days through nanoseconds that exceeds the 2⁵³ limit. So days
cannot be out of range in the CreateDateDurationRecord call.

h/t Anba

Closes: #3028
  • Loading branch information
ptomato committed Dec 5, 2024
1 parent 32ab23a commit 3d5a4cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ <h1>
<h1>
ToDateDurationRecordWithoutTime (
_duration_: a Temporal.Duration,
): either a normal completion containing a Date Duration Record, or a throw completion
): a Date Duration Record
</h1>
<dl class="header">
<dt>description</dt>
Expand All @@ -918,7 +918,7 @@ <h1>
<emu-alg>
1. Let _internalDuration_ be ToInternalDurationRecordWith24HourDays(_duration_).
1. Let _days_ be truncate(_internalDuration_.[[Time]] / nsPerDay).
1. Return ? CreateDateDurationRecord(_internalDuration_.[[Date]].[[Years]], _internalDuration_.[[Date]].[[Months]], _internalDuration_.[[Date]].[[Weeks]], _days_).
1. Return ! CreateDateDurationRecord(_internalDuration_.[[Date]].[[Years]], _internalDuration_.[[Date]].[[Months]], _internalDuration_.[[Date]].[[Weeks]], _days_).
</emu-alg>
</emu-clause>

Expand Down
2 changes: 1 addition & 1 deletion spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ <h1>
1. Let _calendar_ be _temporalDate_.[[Calendar]].
1. Let _duration_ be ? ToTemporalDuration(_temporalDurationLike_).
1. If _operation_ is ~subtract~, set _duration_ to CreateNegatedTemporalDuration(_duration_).
1. Let _dateDuration_ be ? ToDateDurationRecordWithoutTime(_duration_).
1. Let _dateDuration_ be ToDateDurationRecordWithoutTime(_duration_).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_).
1. Let _result_ be ? CalendarDateAdd(_calendar_, _temporalDate_.[[ISODate]], _dateDuration_, _overflow_).
Expand Down
2 changes: 1 addition & 1 deletion spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ <h1>
1. Assert: ISODateWithinLimits(_date_) is *true*.
1. Else,
1. Let _date_ be _intermediateDate_.
1. Let _durationToAdd_ be ? ToDateDurationRecordWithoutTime(_duration_).
1. Let _durationToAdd_ be ToDateDurationRecordWithoutTime(_duration_).
1. Let _addedDate_ be ? CalendarDateAdd(_calendar_, _date_, _durationToAdd_, _overflow_).
1. Let _addedDateFields_ be ISODateToFields(_calendar_, _addedDate_, ~year-month~).
1. Let _isoDate_ be ? CalendarYearMonthFromFields(_calendar_, _addedDateFields_, _overflow_).
Expand Down

0 comments on commit 3d5a4cf

Please sign in to comment.