Skip to content

Commit 5e95761

Browse files
committed
Editorial: Rename UnnormalizeDuration to TemporalDurationFromInternal
See: #2953
1 parent 2c9228b commit 5e95761

File tree

9 files changed

+30
-27
lines changed

9 files changed

+30
-27
lines changed

polyfill/lib/duration.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export class Duration {
247247
roundingMode
248248
);
249249
if (ES.TemporalUnitCategory(largestUnit) === 'date') largestUnit = 'hour';
250-
return ES.UnnormalizeDuration(duration, largestUnit);
250+
return ES.TemporalDurationFromInternal(duration, largestUnit);
251251
}
252252

253253
if (plainRelativeTo) {
@@ -271,7 +271,7 @@ export class Duration {
271271
smallestUnit,
272272
roundingMode
273273
);
274-
return ES.UnnormalizeDuration(duration, largestUnit);
274+
return ES.TemporalDurationFromInternal(duration, largestUnit);
275275
}
276276

277277
// No reference date to calculate difference relative to
@@ -284,7 +284,7 @@ export class Duration {
284284
assert(!ES.IsCalendarUnit(smallestUnit), 'smallestUnit was larger than largestUnit');
285285
let duration = ES.ToInternalDurationRecordWith24HourDays(this);
286286
duration = ES.RoundTimeDuration(duration, roundingIncrement, smallestUnit, roundingMode);
287-
return ES.UnnormalizeDuration(duration, largestUnit);
287+
return ES.TemporalDurationFromInternal(duration, largestUnit);
288288
}
289289
total(totalOf) {
290290
if (!ES.IsTemporalDuration(this)) throw new TypeErrorCtor('invalid receiver');
@@ -351,7 +351,10 @@ export class Duration {
351351
const largestUnit = ES.DefaultTemporalLargestUnit(this);
352352
let duration = ES.ToInternalDurationRecord(this);
353353
duration = ES.RoundTimeDuration(duration, increment, unit, roundingMode);
354-
const roundedDuration = ES.UnnormalizeDuration(duration, ES.LargerOfTwoTemporalUnits(largestUnit, 'second'));
354+
const roundedDuration = ES.TemporalDurationFromInternal(
355+
duration,
356+
ES.LargerOfTwoTemporalUnits(largestUnit, 'second')
357+
);
355358
return ES.TemporalDurationToString(roundedDuration, precision);
356359
}
357360
toJSON() {

polyfill/lib/ecmascript.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,7 @@ function ToDateDurationRecordWithoutTime(duration) {
28592859
return { ...internalDuration.date, days };
28602860
}
28612861

2862-
export function UnnormalizeDuration(internalDuration, largestUnit) {
2862+
export function TemporalDurationFromInternal(internalDuration, largestUnit) {
28632863
const sign = internalDuration.norm.sign();
28642864
let nanoseconds = internalDuration.norm.abs().subsec;
28652865
let microseconds = 0;
@@ -3606,7 +3606,7 @@ export function DifferenceTemporalInstant(operation, instant, other, options) {
36063606
settings.smallestUnit,
36073607
settings.roundingMode
36083608
);
3609-
let result = UnnormalizeDuration(duration, settings.largestUnit);
3609+
let result = TemporalDurationFromInternal(duration, settings.largestUnit);
36103610
if (operation === 'since') result = CreateNegatedTemporalDuration(result);
36113611
return result;
36123612
}
@@ -3648,7 +3648,7 @@ export function DifferenceTemporalPlainDate(operation, plainDate, other, options
36483648
);
36493649
}
36503650

3651-
let result = UnnormalizeDuration(duration, 'day');
3651+
let result = TemporalDurationFromInternal(duration, 'day');
36523652
if (operation === 'since') result = CreateNegatedTemporalDuration(result);
36533653
return result;
36543654
}
@@ -3679,7 +3679,7 @@ export function DifferenceTemporalPlainDateTime(operation, plainDateTime, other,
36793679
settings.roundingMode
36803680
);
36813681

3682-
let result = UnnormalizeDuration(duration, settings.largestUnit);
3682+
let result = TemporalDurationFromInternal(duration, settings.largestUnit);
36833683
if (operation === 'since') result = CreateNegatedTemporalDuration(result);
36843684
return result;
36853685
}
@@ -3696,7 +3696,7 @@ export function DifferenceTemporalPlainTime(operation, plainTime, other, options
36963696
duration = RoundTimeDuration(duration, settings.roundingIncrement, settings.smallestUnit, settings.roundingMode);
36973697
}
36983698

3699-
let result = UnnormalizeDuration(duration, settings.largestUnit);
3699+
let result = TemporalDurationFromInternal(duration, settings.largestUnit);
37003700
if (operation === 'since') result = CreateNegatedTemporalDuration(result);
37013701
return result;
37023702
}
@@ -3743,7 +3743,7 @@ export function DifferenceTemporalPlainYearMonth(operation, yearMonth, other, op
37433743
);
37443744
}
37453745

3746-
let result = UnnormalizeDuration(duration, 'day');
3746+
let result = TemporalDurationFromInternal(duration, 'day');
37473747
if (operation === 'since') result = CreateNegatedTemporalDuration(result);
37483748
return result;
37493749
}
@@ -3774,7 +3774,7 @@ export function DifferenceTemporalZonedDateTime(operation, zonedDateTime, other,
37743774
settings.smallestUnit,
37753775
settings.roundingMode
37763776
);
3777-
result = UnnormalizeDuration(duration, settings.largestUnit);
3777+
result = TemporalDurationFromInternal(duration, settings.largestUnit);
37783778
} else {
37793779
const timeZone = GetSlot(zonedDateTime, TIME_ZONE);
37803780
if (!TimeZoneEquals(timeZone, GetSlot(other, TIME_ZONE))) {
@@ -3796,7 +3796,7 @@ export function DifferenceTemporalZonedDateTime(operation, zonedDateTime, other,
37963796
settings.smallestUnit,
37973797
settings.roundingMode
37983798
);
3799-
result = UnnormalizeDuration(duration, 'hour');
3799+
result = TemporalDurationFromInternal(duration, 'hour');
38003800
}
38013801

38023802
if (operation === 'since') result = CreateNegatedTemporalDuration(result);
@@ -3854,7 +3854,7 @@ export function AddDurations(operation, duration, other) {
38543854
const d1 = ToInternalDurationRecordWith24HourDays(duration);
38553855
const d2 = ToInternalDurationRecordWith24HourDays(other);
38563856
const result = CombineDateAndNormalizedTimeDuration(ZeroDateDuration(), d1.norm.add(d2.norm));
3857-
return UnnormalizeDuration(result, largestUnit);
3857+
return TemporalDurationFromInternal(result, largestUnit);
38583858
}
38593859

38603860
export function AddDurationToInstant(operation, instant, durationLike) {

spec/duration.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ <h1>Temporal.Duration.prototype.round ( _roundTo_ )</h1>
434434
1. Let _targetEpochNs_ be ? AddZonedDateTime(_relativeEpochNs_, _timeZone_, _calendar_, _internalDuration_, ~constrain~).
435435
1. Set _internalDuration_ to ? DifferenceZonedDateTimeWithRounding(_relativeEpochNs_, _targetEpochNs_, _timeZone_, _calendar_, _largestUnit_, _roundingIncrement_, _smallestUnit_, _roundingMode_).
436436
1. If TemporalUnitCategory(_largestUnit_) is ~date~, set _largestUnit_ to ~hour~.
437-
1. Return ? UnnormalizeDuration(_internalDuration_, _largestUnit_).
437+
1. Return ? TemporalDurationFromInternal(_internalDuration_, _largestUnit_).
438438
1. If _plainRelativeTo_ is not *undefined*, then
439439
1. Let _internalDuration_ be ToInternalDurationRecordWith24HourDays(_duration_).
440440
1. Let _targetTime_ be AddTime(MidnightTimeRecord(), _internalDuration_.[[NormalizedTime]]).
@@ -444,12 +444,12 @@ <h1>Temporal.Duration.prototype.round ( _roundTo_ )</h1>
444444
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_plainRelativeTo_.[[ISODate]], MidnightTimeRecord()).
445445
1. Let _targetDateTime_ be CombineISODateAndTimeRecord(_targetDate_, _targetTime_).
446446
1. Set _internalDuration_ to ? DifferencePlainDateTimeWithRounding(_isoDateTime_, _targetDateTime_, _calendar_, _largestUnit_, _roundingIncrement_, _smallestUnit_, _roundingMode_).
447-
1. Return ? UnnormalizeDuration(_internalDuration_, _largestUnit_).
447+
1. Return ? TemporalDurationFromInternal(_internalDuration_, _largestUnit_).
448448
1. If IsCalendarUnit(_existingLargestUnit_) is *true*, or IsCalendarUnit(_largestUnit_) is *true*, throw a *RangeError* exception.
449449
1. Assert: IsCalendarUnit(_smallestUnit_) is *false*.
450450
1. Let _internalDuration_ be ToInternalDurationRecordWith24HourDays(_duration_).
451451
1. Set _internalDuration_ to ? RoundTimeDuration(_internalDuration_, _roundingIncrement_, _smallestUnit_, _roundingMode_).
452-
1. Return ? UnnormalizeDuration(_internalDuration_, _largestUnit_).
452+
1. Return ? TemporalDurationFromInternal(_internalDuration_, _largestUnit_).
453453
</emu-alg>
454454
</emu-clause>
455455

@@ -515,7 +515,7 @@ <h1>Temporal.Duration.prototype.toString ( [ _options_ ] )</h1>
515515
1. Let _internalDuration_ be ToInternalDurationRecord(_duration_).
516516
1. Set _internalDuration_ to ? RoundTimeDuration(_internalDuration_, _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_).
517517
1. Let _roundedLargestUnit_ be LargerOfTwoTemporalUnits(_largestUnit_, ~second~).
518-
1. Let _roundedDuration_ be ! UnnormalizeDuration(_internalDuration_, _roundedLargestUnit_).
518+
1. Let _roundedDuration_ be ! TemporalDurationFromInternal(_internalDuration_, _roundedLargestUnit_).
519519
1. Return TemporalDurationToString(_roundedDuration_, _precision_.[[Precision]]).
520520
</emu-alg>
521521
</emu-clause>
@@ -937,9 +937,9 @@ <h1>
937937
</emu-alg>
938938
</emu-clause>
939939

940-
<emu-clause id="sec-temporal-unnormalizeduration" type="abstract operation">
940+
<emu-clause id="sec-temporal-temporaldurationfrominternal" type="abstract operation">
941941
<h1>
942-
UnnormalizeDuration (
942+
TemporalDurationFromInternal (
943943
_internalDuration_: an Internal Duration Record,
944944
_largestUnit_: a Temporal unit,
945945
): either a normal completion containing a Temporal.Duration, or a throw completion
@@ -2025,7 +2025,7 @@ <h1>
20252025
1. Let _d2_ be ToInternalDurationRecordWith24HourDays(_other_).
20262026
1. Let _normResult_ be ? AddNormalizedTimeDuration(_d1_.[[NormalizedTime]], _d2_.[[NormalizedTime]]).
20272027
1. Let _result_ be ! CombineDateAndNormalizedTimeDuration(ZeroDateDuration(), _normResult_).
2028-
1. Return ? UnnormalizeDuration(_result_, _largestUnit_).
2028+
1. Return ? TemporalDurationFromInternal(_result_, _largestUnit_).
20292029
</emu-alg>
20302030
</emu-clause>
20312031
</emu-clause>

spec/instant.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ <h1>
543543
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
544544
1. Let _settings_ be ? GetDifferenceSettings(_operation_, _resolvedOptions_, ~time~, « », ~nanosecond~, ~second~).
545545
1. Let _internalDuration_ be DifferenceInstant(_instant_.[[EpochNanoseconds]], _other_.[[EpochNanoseconds]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
546-
1. Let _result_ be ! UnnormalizeDuration(_internalDuration_, _settings_.[[LargestUnit]]).
546+
1. Let _result_ be ! TemporalDurationFromInternal(_internalDuration_, _settings_.[[LargestUnit]]).
547547
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
548548
1. Return _result_.
549549
</emu-alg>

spec/plaindate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ <h1>
904904
1. Let _isoDateTimeOther_ be CombineISODateAndTimeRecord(_other_.[[ISODate]], MidnightTimeRecord()).
905905
1. Let _destEpochNs_ be GetUTCEpochNanoseconds(_isoDateTimeOther_).
906906
1. Set _duration_ to ? RoundRelativeDuration(_duration_, _destEpochNs_, _isoDateTime_, ~unset~, _temporalDate_.[[Calendar]], _settings_.[[LargestUnit]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
907-
1. Let _result_ be ! UnnormalizeDuration(_duration_, ~day~).
907+
1. Let _result_ be ! TemporalDurationFromInternal(_duration_, ~day~).
908908
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
909909
1. Return _result_.
910910
</emu-alg>

spec/plaindatetime.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ <h1>
10521052
1. If CompareISODateTime(_dateTime_.[[ISODateTime]], _other_.[[ISODateTime]]) = 0, then
10531053
1. Return ! CreateTemporalDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
10541054
1. Let _internalDuration_ be ? DifferencePlainDateTimeWithRounding(_dateTime_.[[ISODateTime]], _other_.[[ISODateTime]], _dateTime_.[[Calendar]], _settings_.[[LargestUnit]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
1055-
1. Let _result_ be ? UnnormalizeDuration(_internalDuration_, _settings_.[[LargestUnit]]).
1055+
1. Let _result_ be ? TemporalDurationFromInternal(_internalDuration_, _settings_.[[LargestUnit]]).
10561056
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
10571057
1. Return _result_.
10581058
</emu-alg>

spec/plaintime.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ <h1>
935935
1. Let _duration_ be ! CombineDateAndNormalizedTimeDuration(ZeroDateDuration(), _norm_).
936936
1. If _settings_.[[SmallestUnit]] is not ~nanosecond~ or _settings_.[[RoundingIncrement]] ≠ 1, then
937937
1. Set _duration_ to ! RoundTimeDuration(_duration_, _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
938-
1. Let _result_ be ! UnnormalizeDuration(_duration_, _settings_.[[LargestUnit]]).
938+
1. Let _result_ be ! TemporalDurationFromInternal(_duration_, _settings_.[[LargestUnit]]).
939939
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
940940
1. Return _result_.
941941
</emu-alg>

spec/plainyearmonth.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ <h1>
616616
1. Let _isoDateTimeOther_ be CombineISODateAndTimeRecord(_otherDate_, MidnightTimeRecord()).
617617
1. Let _destEpochNs_ be GetUTCEpochNanoseconds(_isoDateTimeOther_).
618618
1. Set _duration_ to ? RoundRelativeDuration(_duration_, _destEpochNs_, _isoDateTime_, ~unset~, _calendar_, _settings_.[[LargestUnit]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).[[Duration]].
619-
1. Let _result_ be ? UnnormalizeDuration(_duration_, ~day~).
619+
1. Let _result_ be ? TemporalDurationFromInternal(_duration_, ~day~).
620620
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
621621
1. Return _result_.
622622
</emu-alg>

spec/zoneddatetime.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ <h1>
12151215
1. Let _settings_ be ? GetDifferenceSettings(_operation_, _resolvedOptions_, ~datetime~, « », ~nanosecond~, ~hour~).
12161216
1. If TemporalUnitCategory(_settings_.[[LargestUnit]]) is not ~date~, then
12171217
1. Let _internalDuration_ be DifferenceInstant(_zonedDateTime_.[[EpochNanoseconds]], _other_.[[EpochNanoseconds]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
1218-
1. Let _result_ be ! UnnormalizeDuration(_internalDuration_, _settings_.[[LargestUnit]]).
1218+
1. Let _result_ be ! TemporalDurationFromInternal(_internalDuration_, _settings_.[[LargestUnit]]).
12191219
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
12201220
1. Return _result_.
12211221
1. NOTE: To calculate differences in two different time zones, _settings_.[[LargestUnit]] must be a time unit, because day lengths can vary between time zones due to DST and other UTC offset shifts.
@@ -1224,7 +1224,7 @@ <h1>
12241224
1. If _zonedDateTime_.[[EpochNanoseconds]] = _other_.[[EpochNanoseconds]], then
12251225
1. Return ! CreateTemporalDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
12261226
1. Let _internalDuration_ be ? DifferenceZonedDateTimeWithRounding(_zonedDateTime_.[[EpochNanoseconds]], _other_.[[EpochNanoseconds]], _zonedDateTime_.[[TimeZone]], _zonedDateTime_.[[Calendar]], _settings_.[[LargestUnit]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
1227-
1. Let _result_ be ? UnnormalizeDuration(_internalDuration_, ~hour~).
1227+
1. Let _result_ be ? TemporalDurationFromInternal(_internalDuration_, ~hour~).
12281228
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
12291229
1. Return _result_.
12301230
</emu-alg>

0 commit comments

Comments
 (0)