Skip to content

Commit 00958d0

Browse files
ptomatoMs2ger
authored andcommitted
Editorial: Move IsValidDuration check into ToTemporalDurationRecord
This does not change anything observable because directly after all call sites of ToTemporalDurationRecord, IsValidDuration was checked anyway. However, this way is conceptually easier because it implements the invariant that no Duration Record can be created with invalid values in it.
1 parent 6e59366 commit 00958d0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spec/duration.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ <h1>
920920
1. Else,
921921
1. Let _string_ be ? ToString(_item_).
922922
1. Let _result_ be ? ParseTemporalDurationString(_string_).
923-
1. Return ? CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]).
923+
1. Return ! CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]).
924924
</emu-alg>
925925
</emu-clause>
926926

@@ -950,6 +950,8 @@ <h1>
950950
1. Set _result_'s field whose name is the Field Name value of the current row to _val_.
951951
1. If _any_ is *false*, then
952952
1. Throw a *TypeError* exception.
953+
1. If ! IsValidDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]] _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]) is *false*, then
954+
1. Throw a *RangeError* exception.
953955
1. Return _result_.
954956
</emu-alg>
955957
</emu-clause>
@@ -1787,7 +1789,6 @@ <h1>
17871789
1. Let _duration_ be ? ParseTemporalDurationString(_str_).
17881790
1. Else,
17891791
1. Let _duration_ be ? ToTemporalDurationRecord(_temporalDurationLike_).
1790-
1. If ! IsValidDuration(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]) is *false*, throw a *RangeError* exception.
17911792
1. For each row of <emu-xref href="#table-temporal-duration-record-fields"></emu-xref>, except the header row, in table order, do
17921793
1. Let _prop_ be the Property Name value of the current row.
17931794
1. Let _value_ be _duration_'s field whose name is the Field Name value of the current row.

0 commit comments

Comments
 (0)