Skip to content

Commit 0b1346c

Browse files
ptomatoMs2ger
authored andcommitted
Editorial: Change NanosecondsToDays to take an integer
It currently takes a BigInt value but is immediately converted to an mathematical integer anyway, at the beginning of the operation.
1 parent ffd1b84 commit 0b1346c

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

spec/duration.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,17 +1207,16 @@ <h1>
12071207
1. If _relativeTo_ is not present, set _relativeTo_ to *undefined*.
12081208
1. If Type(_relativeTo_) is Object and _relativeTo_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
12091209
1. Let _endNs_ be ? AddZonedDateTime(_relativeTo_.[[Nanoseconds]], _relativeTo_.[[TimeZone]], _relativeTo_.[[Calendar]], 0, 0, 0, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_).
1210-
1. Set _nanoseconds_ to _endNs__relativeTo_.[[Nanoseconds]].
1210+
1. Set _nanoseconds_ to ℝ(_endNs__relativeTo_.[[Nanoseconds]]).
12111211
1. Else,
1212-
1. Set _nanoseconds_ to ℤ(! TotalDurationNanoseconds(_days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_, 0)).
1212+
1. Set _nanoseconds_ to ! TotalDurationNanoseconds(_days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_, 0).
12131213
1. If _largestUnit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*, then
12141214
1. Let _result_ be ? NanosecondsToDays(_nanoseconds_, _relativeTo_).
12151215
1. Set _days_ to _result_.[[Days]].
12161216
1. Set _nanoseconds_ to _result_.[[Nanoseconds]].
12171217
1. Else,
12181218
1. Set _days_ to 0.
12191219
1. Set _hours_, _minutes_, _seconds_, _milliseconds_, and _microseconds_ to 0.
1220-
1. Set _nanoseconds_ to ℝ(_nanoseconds_).
12211220
1. If _nanoseconds_ &lt; 0, let _sign_ be −1; else, let _sign_ be 1.
12221221
1. Set _nanoseconds_ to abs(_nanoseconds_).
12231222
1. If _largestUnit_ is *"year"*, *"month"*, *"week"*, *"day"*, or *"hour"*, then

spec/zoneddatetime.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ <h1>DifferenceZonedDateTime ( _ns1_, _ns2_, _timeZone_, _calendar_, _largestUnit
12761276
1. Let _intermediateNs_ be ? AddZonedDateTime(_ns1_, _timeZone_, _calendar_, _dateDifference_.[[Years]], _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], 0, 0, 0, 0, 0, 0, 0).
12771277
1. Let _timeRemainderNs_ be _ns2__intermediateNs_.
12781278
1. Let _intermediate_ be ! CreateTemporalZonedDateTime(_intermediateNs_, _timeZone_, _calendar_).
1279-
1. Let _result_ be ? NanosecondsToDays(_timeRemainderNs_, _intermediate_).
1279+
1. Let _result_ be ? NanosecondsToDays(ℝ(_timeRemainderNs_), _intermediate_).
12801280
1. Let _timeDifference_ be ! BalanceDuration(0, 0, 0, 0, 0, 0, _result_.[[Nanoseconds]], *"hour"*).
12811281
1. Return ! CreateDurationRecord(_dateDifference_.[[Years]], _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], _result_.[[Days]], _timeDifference_.[[Hours]], _timeDifference_.[[Minutes]], _timeDifference_.[[Seconds]], _timeDifference_.[[Milliseconds]], _timeDifference_.[[Microseconds]], _timeDifference_.[[Nanoseconds]]).
12821282
</emu-alg>
@@ -1285,7 +1285,7 @@ <h1>DifferenceZonedDateTime ( _ns1_, _ns2_, _timeZone_, _calendar_, _largestUnit
12851285
<emu-clause id="sec-temporal-nanosecondstodays" type="abstract operation">
12861286
<h1>
12871287
NanosecondsToDays (
1288-
_nanoseconds_: a BigInt value,
1288+
_nanoseconds_: an integer,
12891289
_relativeTo_: *undefined*, a Temporal.PlainDate, or a Temporal.ZonedDateTime,
12901290
)
12911291
</h1>
@@ -1298,8 +1298,6 @@ <h1>
12981298
</dd>
12991299
</dl>
13001300
<emu-alg>
1301-
1. Assert: Type(_nanoseconds_) is BigInt.
1302-
1. Set _nanoseconds_ to ℝ(_nanoseconds_).
13031301
1. Let _dayLengthNs_ be 8.64 × 10<sup>13</sup>.
13041302
1. If _nanoseconds_ = 0, then
13051303
1. Return the Record { [[Days]]: 0, [[Nanoseconds]]: 0, [[DayLength]]: _dayLengthNs_ }.

0 commit comments

Comments
 (0)