Skip to content

Commit

Permalink
Normative: Use floor instead of truncate in epoch time getters
Browse files Browse the repository at this point in the history
In Temporal.{Instant,ZonedDateTime}.epoch{S,Millis,Micros}econds, the
rounding should use floor instead of truncate semantics, in order to
always truncate towards the beginning of time, as .toString() and .round()
do.

Closes: #2423
  • Loading branch information
ptomato committed Nov 29, 2022
1 parent 6463f32 commit c0209c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions spec/instant.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h1>get Temporal.Instant.prototype.epochSeconds</h1>
1. Let _instant_ be the *this* value.
1. Perform ? RequireInternalSlot(_instant_, [[InitializedTemporalInstant]]).
1. Let _ns_ be _instant_.[[Nanoseconds]].
1. Let _s_ be truncate(ℝ(_ns_) / 10<sup>9</sup>).
1. Let _s_ be floor(ℝ(_ns_) / 10<sup>9</sup>).
1. Return 𝔽(_s_).
</emu-alg>
</emu-clause>
Expand All @@ -177,7 +177,7 @@ <h1>get Temporal.Instant.prototype.epochMilliseconds</h1>
1. Let _instant_ be the *this* value.
1. Perform ? RequireInternalSlot(_instant_, [[InitializedTemporalInstant]]).
1. Let _ns_ be _instant_.[[Nanoseconds]].
1. Let _ms_ be truncate(ℝ(_ns_) / 10<sup>6</sup>).
1. Let _ms_ be floor(ℝ(_ns_) / 10<sup>6</sup>).
1. Return 𝔽(_ms_).
</emu-alg>
</emu-clause>
Expand All @@ -192,7 +192,7 @@ <h1>get Temporal.Instant.prototype.epochMicroseconds</h1>
1. Let _instant_ be the *this* value.
1. Perform ? RequireInternalSlot(_instant_, [[InitializedTemporalInstant]]).
1. Let _ns_ be _instant_.[[Nanoseconds]].
1. Let _µs_ be truncate(ℝ(_ns_) / 10<sup>3</sup>).
1. Let _µs_ be floor(ℝ(_ns_) / 10<sup>3</sup>).
1. Return ℤ(_µs_).
</emu-alg>
</emu-clause>
Expand Down
6 changes: 3 additions & 3 deletions spec/zoneddatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ <h1>get Temporal.ZonedDateTime.prototype.epochSeconds</h1>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Let _ns_ be _zonedDateTime_.[[Nanoseconds]].
1. Let _s_ be truncate(ℝ(_ns_) / 10<sup>9</sup>).
1. Let _s_ be floor(ℝ(_ns_) / 10<sup>9</sup>).
1. Return 𝔽(_s_).
</emu-alg>
</emu-clause>
Expand All @@ -328,7 +328,7 @@ <h1>get Temporal.ZonedDateTime.prototype.epochMilliseconds</h1>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Let _ns_ be _zonedDateTime_.[[Nanoseconds]].
1. Let _ms_ be truncate(ℝ(_ns_) / 10<sup>6</sup>).
1. Let _ms_ be floor(ℝ(_ns_) / 10<sup>6</sup>).
1. Return 𝔽(_ms_).
</emu-alg>
</emu-clause>
Expand All @@ -343,7 +343,7 @@ <h1>get Temporal.ZonedDateTime.prototype.epochMicroseconds</h1>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Let _ns_ be _zonedDateTime_.[[Nanoseconds]].
1. Let _µs_ be truncate(ℝ(_ns_) / 10<sup>3</sup>).
1. Let _µs_ be floor(ℝ(_ns_) / 10<sup>3</sup>).
1. Return ℤ(_µs_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit c0209c2

Please sign in to comment.