@@ -2564,7 +2564,7 @@ function DateDurationSign(dateDuration) {
2564
2564
return 0 ;
2565
2565
}
2566
2566
2567
- function NormalizedDurationSign ( duration ) {
2567
+ function InternalDurationSign ( duration ) {
2568
2568
const dateSign = DateDurationSign ( duration . date ) ;
2569
2569
if ( dateSign !== 0 ) return dateSign ;
2570
2570
return duration . norm . sign ( ) ;
@@ -2805,7 +2805,7 @@ export function RejectDuration(y, mon, w, d, h, min, s, ms, µs, ns) {
2805
2805
}
2806
2806
}
2807
2807
2808
- export function NormalizeDuration ( duration ) {
2808
+ export function ToInternalDurationRecord ( duration ) {
2809
2809
const date = {
2810
2810
years : GetSlot ( duration , YEARS ) ,
2811
2811
months : GetSlot ( duration , MONTHS ) ,
@@ -2823,7 +2823,7 @@ export function NormalizeDuration(duration) {
2823
2823
return { date, norm } ;
2824
2824
}
2825
2825
2826
- export function NormalizeDurationWith24HourDays ( duration ) {
2826
+ export function ToInternalDurationRecordWith24HourDays ( duration ) {
2827
2827
const norm = TimeDuration . normalize (
2828
2828
GetSlot ( duration , HOURS ) ,
2829
2829
GetSlot ( duration , MINUTES ) ,
@@ -2841,13 +2841,13 @@ export function NormalizeDurationWith24HourDays(duration) {
2841
2841
return { date, norm } ;
2842
2842
}
2843
2843
2844
- function NormalizeDurationWithoutTime ( duration ) {
2845
- const normalizedDuration = NormalizeDurationWith24HourDays ( duration ) ;
2846
- const days = MathTrunc ( normalizedDuration . norm . sec / 86400 ) ;
2844
+ function ToDateDurationRecordWithoutTime ( duration ) {
2845
+ const internalDuration = ToInternalDurationRecordWith24HourDays ( duration ) ;
2846
+ const days = MathTrunc ( internalDuration . norm . sec / 86400 ) ;
2847
2847
RejectDuration (
2848
- normalizedDuration . date . years ,
2849
- normalizedDuration . date . months ,
2850
- normalizedDuration . date . weeks ,
2848
+ internalDuration . date . years ,
2849
+ internalDuration . date . months ,
2850
+ internalDuration . date . weeks ,
2851
2851
days ,
2852
2852
0 ,
2853
2853
0 ,
@@ -2856,15 +2856,15 @@ function NormalizeDurationWithoutTime(duration) {
2856
2856
0 ,
2857
2857
0
2858
2858
) ;
2859
- return { ...normalizedDuration . date , days } ;
2859
+ return { ...internalDuration . date , days } ;
2860
2860
}
2861
2861
2862
- export function UnnormalizeDuration ( normalizedDuration , largestUnit ) {
2863
- const sign = normalizedDuration . norm . sign ( ) ;
2864
- let nanoseconds = normalizedDuration . norm . abs ( ) . subsec ;
2862
+ export function UnnormalizeDuration ( internalDuration , largestUnit ) {
2863
+ const sign = internalDuration . norm . sign ( ) ;
2864
+ let nanoseconds = internalDuration . norm . abs ( ) . subsec ;
2865
2865
let microseconds = 0 ;
2866
2866
let milliseconds = 0 ;
2867
- let seconds = normalizedDuration . norm . abs ( ) . sec ;
2867
+ let seconds = internalDuration . norm . abs ( ) . sec ;
2868
2868
let minutes = 0 ;
2869
2869
let hours = 0 ;
2870
2870
let days = 0 ;
@@ -2939,10 +2939,10 @@ export function UnnormalizeDuration(normalizedDuration, largestUnit) {
2939
2939
2940
2940
const TemporalDuration = GetIntrinsic ( '%Temporal.Duration%' ) ;
2941
2941
return new TemporalDuration (
2942
- normalizedDuration . date . years ,
2943
- normalizedDuration . date . months ,
2944
- normalizedDuration . date . weeks ,
2945
- normalizedDuration . date . days + sign * days ,
2942
+ internalDuration . date . years ,
2943
+ internalDuration . date . months ,
2944
+ internalDuration . date . weeks ,
2945
+ internalDuration . date . days + sign * days ,
2946
2946
sign * hours ,
2947
2947
sign * minutes ,
2948
2948
sign * seconds ,
@@ -3014,7 +3014,7 @@ function DifferenceISODateTime(isoDateTime1, isoDateTime2, calendar, largestUnit
3014
3014
const dateLargestUnit = LargerOfTwoTemporalUnits ( 'day' , largestUnit ) ;
3015
3015
const dateDifference = CalendarDateUntil ( calendar , isoDateTime1 . isoDate , adjustedDate , dateLargestUnit ) ;
3016
3016
if ( largestUnit !== dateLargestUnit ) {
3017
- // largestUnit < days, so add the days in to the normalized duration
3017
+ // largestUnit < days, so add the days in to the internal duration
3018
3018
timeDuration = timeDuration . add24HourDays ( dateDifference . days ) ;
3019
3019
dateDifference . days = 0 ;
3020
3020
}
@@ -3381,7 +3381,7 @@ function RoundRelativeDuration(
3381
3381
// >24 hours in its timezone. (should automatically end up like this if using
3382
3382
// non-rounding since/until internal methods prior)
3383
3383
const irregularLengthUnit = IsCalendarUnit ( smallestUnit ) || ( timeZone && smallestUnit === 'day' ) ;
3384
- const sign = NormalizedDurationSign ( duration ) < 0 ? - 1 : 1 ;
3384
+ const sign = InternalDurationSign ( duration ) < 0 ? - 1 : 1 ;
3385
3385
3386
3386
let nudgeResult ;
3387
3387
if ( irregularLengthUnit ) {
@@ -3444,7 +3444,7 @@ function TotalRelativeDuration(duration, destEpochNs, isoDateTime, timeZone, cal
3444
3444
// non-rounding since/until internal methods prior)
3445
3445
if ( IsCalendarUnit ( unit ) || ( timeZone && unit === 'day' ) ) {
3446
3446
// Rounding an irregular-length unit? Use epoch-nanosecond-bounding technique
3447
- const sign = NormalizedDurationSign ( duration ) < 0 ? - 1 : 1 ;
3447
+ const sign = InternalDurationSign ( duration ) < 0 ? - 1 : 1 ;
3448
3448
return NudgeToCalendarUnit ( sign , duration , destEpochNs , isoDateTime , timeZone , calendar , 1 , unit , 'trunc' ) . total ;
3449
3449
}
3450
3450
// Rounding uniform-length days/hours/minutes/etc units. Simple nanosecond
@@ -3851,8 +3851,8 @@ export function AddDurations(operation, duration, other) {
3851
3851
) ;
3852
3852
}
3853
3853
3854
- const d1 = NormalizeDurationWith24HourDays ( duration ) ;
3855
- const d2 = NormalizeDurationWith24HourDays ( other ) ;
3854
+ const d1 = ToInternalDurationRecordWith24HourDays ( duration ) ;
3855
+ const d2 = ToInternalDurationRecordWith24HourDays ( other ) ;
3856
3856
const result = CombineDateAndNormalizedTimeDuration ( ZeroDateDuration ( ) , d1 . norm . add ( d2 . norm ) ) ;
3857
3857
return UnnormalizeDuration ( result , largestUnit ) ;
3858
3858
}
@@ -3866,8 +3866,8 @@ export function AddDurationToInstant(operation, instant, durationLike) {
3866
3866
`Duration field ${ largestUnit } not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`
3867
3867
) ;
3868
3868
}
3869
- const normalizedDuration = NormalizeDurationWith24HourDays ( duration ) ;
3870
- const ns = AddInstant ( GetSlot ( instant , EPOCHNANOSECONDS ) , normalizedDuration . norm ) ;
3869
+ const internalDuration = ToInternalDurationRecordWith24HourDays ( duration ) ;
3870
+ const ns = AddInstant ( GetSlot ( instant , EPOCHNANOSECONDS ) , internalDuration . norm ) ;
3871
3871
const Instant = GetIntrinsic ( '%Temporal.Instant%' ) ;
3872
3872
return new Instant ( ns ) ;
3873
3873
}
@@ -3877,7 +3877,7 @@ export function AddDurationToDate(operation, plainDate, durationLike, options) {
3877
3877
3878
3878
let duration = ToTemporalDuration ( durationLike ) ;
3879
3879
if ( operation === 'subtract' ) duration = CreateNegatedTemporalDuration ( duration ) ;
3880
- const dateDuration = NormalizeDurationWithoutTime ( duration ) ;
3880
+ const dateDuration = ToDateDurationRecordWithoutTime ( duration ) ;
3881
3881
3882
3882
const resolvedOptions = GetOptionsObject ( options ) ;
3883
3883
const overflow = GetTemporalOverflowOption ( resolvedOptions ) ;
@@ -3894,12 +3894,12 @@ export function AddDurationToDateTime(operation, dateTime, durationLike, options
3894
3894
3895
3895
const calendar = GetSlot ( dateTime , CALENDAR ) ;
3896
3896
3897
- const normalizedDuration = NormalizeDurationWith24HourDays ( duration ) ;
3897
+ const internalDuration = ToInternalDurationRecordWith24HourDays ( duration ) ;
3898
3898
3899
3899
// Add the time part
3900
3900
const isoDateTime = GetSlot ( dateTime , ISO_DATE_TIME ) ;
3901
- const timeResult = AddTime ( isoDateTime . time , normalizedDuration . norm ) ;
3902
- const dateDuration = AdjustDateDurationRecord ( normalizedDuration . date , timeResult . deltaDays ) ;
3901
+ const timeResult = AddTime ( isoDateTime . time , internalDuration . norm ) ;
3902
+ const dateDuration = AdjustDateDurationRecord ( internalDuration . date , timeResult . deltaDays ) ;
3903
3903
3904
3904
// Delegate the date part addition to the calendar
3905
3905
RejectDuration ( dateDuration . years , dateDuration . months , dateDuration . weeks , dateDuration . days , 0 , 0 , 0 , 0 , 0 , 0 ) ;
@@ -3912,10 +3912,10 @@ export function AddDurationToDateTime(operation, dateTime, durationLike, options
3912
3912
export function AddDurationToTime ( operation , temporalTime , durationLike ) {
3913
3913
let duration = ToTemporalDuration ( durationLike ) ;
3914
3914
if ( operation === 'subtract' ) duration = CreateNegatedTemporalDuration ( duration ) ;
3915
- const normalizedDuration = NormalizeDurationWith24HourDays ( duration ) ;
3915
+ const internalDuration = ToInternalDurationRecordWith24HourDays ( duration ) ;
3916
3916
const { hour, minute, second, millisecond, microsecond, nanosecond } = AddTime (
3917
3917
GetSlot ( temporalTime , TIME ) ,
3918
- normalizedDuration . norm
3918
+ internalDuration . norm
3919
3919
) ;
3920
3920
const time = RegulateTime ( hour , minute , second , millisecond , microsecond , nanosecond , 'reject' ) ;
3921
3921
return CreateTemporalTime ( time ) ;
@@ -3936,7 +3936,7 @@ export function AddDurationToYearMonth(operation, yearMonth, durationLike, optio
3936
3936
const nextMonth = CalendarDateAdd ( calendar , startDate , { months : 1 } , 'constrain' ) ;
3937
3937
startDate = BalanceISODate ( nextMonth . year , nextMonth . month , nextMonth . day - 1 ) ;
3938
3938
}
3939
- const durationToAdd = NormalizeDurationWithoutTime ( duration ) ;
3939
+ const durationToAdd = ToDateDurationRecordWithoutTime ( duration ) ;
3940
3940
RejectDateRange ( startDate ) ;
3941
3941
const addedDate = CalendarDateAdd ( calendar , startDate , durationToAdd , overflow ) ;
3942
3942
const addedDateFields = ISODateToFields ( calendar , addedDate , 'year-month' ) ;
@@ -3953,7 +3953,7 @@ export function AddDurationToZonedDateTime(operation, zonedDateTime, durationLik
3953
3953
const overflow = GetTemporalOverflowOption ( resolvedOptions ) ;
3954
3954
const timeZone = GetSlot ( zonedDateTime , TIME_ZONE ) ;
3955
3955
const calendar = GetSlot ( zonedDateTime , CALENDAR ) ;
3956
- const normalized = NormalizeDuration ( duration ) ;
3956
+ const normalized = ToInternalDurationRecord ( duration ) ;
3957
3957
const epochNanoseconds = AddZonedDateTime (
3958
3958
GetSlot ( zonedDateTime , EPOCHNANOSECONDS ) ,
3959
3959
timeZone ,
0 commit comments