Skip to content

Commit

Permalink
fixup! Normative: Precalculate PlainDateTime from ZonedDateTime in mo…
Browse files Browse the repository at this point in the history
…re places
  • Loading branch information
ptomato committed Sep 26, 2023
1 parent 5fa8704 commit 36cf559
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions polyfill/lib/duration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ export class Duration {
let precalculatedPlainDateTime;
const plainDateTimeOrRelativeToWillBeUsed =
!roundingGranularityIsNoop ||
largestUnit === 'year' ||
largestUnit === 'month' ||
largestUnit === 'week' ||
largestUnit === 'day' ||
smallestUnit === 'year' ||
smallestUnit === 'month' ||
smallestUnit === 'week' ||
Expand Down
2 changes: 1 addition & 1 deletion spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ <h1>Temporal.Duration.prototype.round ( _roundTo_ )</h1>
1. NOTE: The above conditions mean that the operation will have no effect: the smallest unit and rounding increment will leave the total duration unchanged, and it can be determined without calling a calendar or time zone method that no balancing will take place.
1. Return ! CreateTemporalDuration(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]).
1. Let _precalculatedPlainDateTime_ be *undefined*.
1. If _roundingGranularityIsNoop_ is *false*, or _smallestUnit_ is *"year"*, or _smallestUnit_ is *"month"*, or _smallestUnit_ is *"week"*, or _smallestUnit_ is *"day"*, or _calendarUnitsPresent_ is *true*, or _duration_.[[Days]] &ne; 0, let _plainDateTimeOrRelativeToWillBeUsed_ be *true*; else let _plainDateTimeOrRelativeToWillBeUsed_ be *false*.
1. If _roundingGranularityIsNoop_ is *false*, or _largestUnit_ is *"year"*, or _largestUnit_ is *"month"*, or _largestUnit_ is *"week"*, or _largestUnit_ is *"day"*, or _smallestUnit_ is *"year"*, or _smallestUnit_ is *"month"*, or _smallestUnit_ is *"week"*, or _smallestUnit_ is *"day"*, or _calendarUnitsPresent_ is *true*, or _duration_.[[Days]] &ne; 0, let _plainDateTimeOrRelativeToWillBeUsed_ be *true*; else let _plainDateTimeOrRelativeToWillBeUsed_ be *false*.
1. If _zonedRelativeTo_ is not *undefined* and _plainDateTimeOrRelativeToWillBeUsed_ is *true*, then
1. NOTE: The above conditions mean that the corresponding `Temporal.PlainDateTime` or `Temporal.PlainDate` for _zonedRelativeTo_ will be used in one of the operations below.
1. Let _instant_ be ! CreateTemporalInstant(_zonedRelativeTo_.[[Nanoseconds]]).
Expand Down

0 comments on commit 36cf559

Please sign in to comment.