Skip to content

Commit 03770bb

Browse files
committed
Move IsValidDuration from ECMA-402 into ECMA-262
ToIntegerIfIntegral no longer needs to be defined by Temporal, as it's now part of ECMA-402. However, when Temporal becomes part of ECMA-262, we do need to move ToIntegerIfIntegral into ECMA-262. Put it in a <del> block in intl.html. We can keep the new definition in its current place in the spec while adjusting its ID.
1 parent 5f76109 commit 03770bb

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

spec/duration.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ <h1>
11491149
</emu-alg>
11501150
</emu-clause>
11511151

1152-
<emu-clause id="sec-temporal-isvalidduration" type="abstract operation">
1152+
<emu-clause id="sec-isvalidduration" type="abstract operation">
11531153
<h1>
11541154
IsValidDuration (
11551155
_years_: an integer,
@@ -1166,7 +1166,7 @@ <h1>
11661166
</h1>
11671167
<dl class="header">
11681168
<dt>description</dt>
1169-
<dd>It returns *true* if its arguments form valid input from which to construct a `Temporal.Duration`, and *false* otherwise.</dd>
1169+
<dd>It returns *true* if its arguments form valid input from which to construct a <del>Duration Record</del><ins>Temporal.Duration</ins>, and *false* otherwise.</dd>
11701170
</dl>
11711171
<emu-alg>
11721172
1. Let _sign_ be 0.
@@ -1181,9 +1181,9 @@ <h1>
11811181
1. If abs(_years_) ≥ 2<sup>32</sup>, return *false*.
11821182
1. If abs(_months_) ≥ 2<sup>32</sup>, return *false*.
11831183
1. If abs(_weeks_) ≥ 2<sup>32</sup>, return *false*.
1184-
1. Let _totalFractionalSeconds_ be _days_ × 86,400 + _hours_ × 3600 + _minutes_ × 60 + _seconds_ + ℝ(𝔽(_milliseconds_)) × 10<sup>-3</sup> + ℝ(𝔽(_microseconds_)) × 10<sup>-6</sup> + ℝ(𝔽(_nanoseconds_)) × 10<sup>-9</sup>.
1184+
1. Let _normalizedSeconds_ be _days_ × 86,400 + _hours_ × 3600 + _minutes_ × 60 + _seconds_ + ℝ(𝔽(_milliseconds_)) × 10<sup>-3</sup> + ℝ(𝔽(_microseconds_)) × 10<sup>-6</sup> + ℝ(𝔽(_nanoseconds_)) × 10<sup>-9</sup>.
11851185
1. NOTE: The above step cannot be implemented directly using floating-point arithmetic. Multiplying by 10<sup>-3</sup>, 10<sup>-6</sup>, and 10<sup>-9</sup> respectively may be imprecise when _milliseconds_, _microseconds_, or _nanoseconds_ is an unsafe integer. This multiplication can be implemented in C++ with an implementation of `std::remquo()` with sufficient bits in the quotient. String manipulation will also give an exact result, since the multiplication is by a power of 10.
1186-
1. If abs(_totalFractionalSeconds_) ≥ 2<sup>53</sup>, return *false*.
1186+
1. If abs(_normalizedSeconds_) ≥ 2<sup>53</sup>, return *false*.
11871187
1. Return *true*.
11881188
</emu-alg>
11891189
</emu-clause>

spec/intl.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,49 @@ <h1>
13291329
</emu-alg>
13301330
</emu-clause>
13311331
</del>
1332+
1333+
<del class="block">
1334+
<emu-clause id="sec-isvalidduration-deleted" type="abstract operation">
1335+
<h1>
1336+
IsValidDuration (
1337+
_years_: an integer,
1338+
_months_: an integer,
1339+
_weeks_: an integer,
1340+
_days_: an integer,
1341+
_hours_: an integer,
1342+
_minutes_: an integer,
1343+
_seconds_: an integer,
1344+
_milliseconds_: an integer,
1345+
_microseconds_: an integer,
1346+
_nanoseconds_: an integer,
1347+
): a Boolean
1348+
</h1>
1349+
<dl class="header">
1350+
<dt>description</dt>
1351+
<dd>It returns *true* if its arguments form valid input from which to construct a Duration Record, and *false* otherwise.</dd>
1352+
<dt>redefinition</dt>
1353+
<dd>true</dd>
1354+
</dl>
1355+
<emu-alg>
1356+
1. Let _sign_ be 0.
1357+
1. For each value _v_ of « _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_ », do
1358+
1. If 𝔽(_v_) is not finite, return *false*.
1359+
1. If _v_ &lt; 0, then
1360+
1. If _sign_ > 0, return *false*.
1361+
1. Set _sign_ to -1.
1362+
1. Else if _v_ > 0, then
1363+
1. If _sign_ &lt; 0, return *false*.
1364+
1. Set _sign_ to 1.
1365+
1. If abs(_years_) ≥ 2<sup>32</sup>, return *false*.
1366+
1. If abs(_months_) ≥ 2<sup>32</sup>, return *false*.
1367+
1. If abs(_weeks_) ≥ 2<sup>32</sup>, return *false*.
1368+
1. Let _normalizedSeconds_ be _days_ × 86,400 + _hours_ × 3600 + _minutes_ × 60 + _seconds_ + ℝ(𝔽(_milliseconds_)) × 10<sup>-3</sup> + ℝ(𝔽(_microseconds_)) × 10<sup>-6</sup> + ℝ(𝔽(_nanoseconds_)) × 10<sup>-9</sup>.
1369+
1. NOTE: The above step cannot be implemented directly using floating-point arithmetic. Multiplying by 10<sup>-3</sup>, 10<sup>-6</sup>, and 10<sup>-9</sup> respectively may be imprecise when _milliseconds_, _microseconds_, or _nanoseconds_ is an unsafe integer. This multiplication can be implemented in C++ with an implementation of `std::remquo()` with sufficient bits in the quotient. String manipulation will also give an exact result, since the multiplication is by a power of 10.
1370+
1. If abs(_normalizedSeconds_) ≥ 2<sup>53</sup>, return *false*.
1371+
1. Return *true*.
1372+
</emu-alg>
1373+
</emu-clause>
1374+
</del>
13321375
</emu-clause>
13331376

13341377
<emu-clause id="locale-sensitive-functions">

0 commit comments

Comments
 (0)