Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: minor DRY refactor for RoundDuration #1968

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3897,12 +3897,7 @@ export const ES = ObjectAssign({}, ES2020, {
if (relativeTo) {
if (ES.IsTemporalZonedDateTime(relativeTo)) {
zdtRelative = relativeTo;
const pdt = ES.BuiltinTimeZoneGetPlainDateTimeFor(
GetSlot(relativeTo, TIME_ZONE),
GetSlot(relativeTo, INSTANT),
GetSlot(relativeTo, CALENDAR)
);
relativeTo = ES.TemporalDateTimeToDate(pdt);
relativeTo = ES.ToTemporalDate(relativeTo);
} else if (!ES.IsTemporalDate(relativeTo)) {
throw new TypeError('starting point must be PlainDate or ZonedDateTime');
}
Expand Down
6 changes: 3 additions & 3 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1247,13 +1247,13 @@ <h1>RoundDuration ( _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _sec
1. Let _zonedRelativeTo_ be *undefined*.
1. If _relativeTo_ is not *undefined*, then
1. If _relativeTo_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
1. Let _instant_ be ! CreateTemporalInstant(_relativeTo_.[[Nanoseconds]]).
1. Set _zonedRelativeTo_ to _relativeTo_.
1. Let _plainDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_relativeTo_.[[TimeZone]], _instant_, _relativeTo_.[[Calendar]]).
1. Set _relativeTo_ to ! CreateTemporalDate(_plainDateTime_.[[ISOYear]], _plainDateTime_.[[ISOMonth]], _plainDateTime_.[[ISODay]], _relativeTo_.[[Calendar]]).
1. Set _relativeTo_ to ? ToTemporalDate(_relativeTo_).
1. Else,
1. Assert: _relativeTo_ has an [[InitializedTemporalDate]] internal slot.
1. Let _calendar_ be _relativeTo_.[[Calendar]].
1. Else,
1. NOTE: _calendar_ will not be used below.
1. If _unit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*, then
1. Let _nanoseconds_ be ! TotalDurationNanoseconds(0, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_, 0).
1. Let _intermediate_ be *undefined*.
Expand Down