@@ -881,6 +881,8 @@ export const ES = ObjectAssign({}, ES2020, {
881
881
calendar = ES . GetOptionalTemporalCalendar ( relativeTo ) ;
882
882
const fieldNames = ES . CalendarFields ( calendar , [ 'day' , 'month' , 'monthCode' , 'year' ] ) ;
883
883
const fields = ES . ToTemporalDateTimeFields ( relativeTo , fieldNames ) ;
884
+ const dateOptions = ObjectCreate ( null ) ;
885
+ dateOptions . overflow = 'constrain' ;
884
886
( {
885
887
year,
886
888
month,
@@ -891,7 +893,7 @@ export const ES = ObjectAssign({}, ES2020, {
891
893
millisecond,
892
894
microsecond,
893
895
nanosecond
894
- } = ES . InterpretTemporalDateTimeFields ( calendar , fields , { overflow : 'constrain' } ) ) ;
896
+ } = ES . InterpretTemporalDateTimeFields ( calendar , fields , dateOptions ) ) ;
895
897
offset = relativeTo . offset ;
896
898
timeZone = relativeTo . timeZone ;
897
899
} else {
@@ -1161,7 +1163,7 @@ export const ES = ObjectAssign({}, ES2020, {
1161
1163
return ES . PrepareTemporalFields ( bag , entries ) ;
1162
1164
} ,
1163
1165
1164
- ToTemporalDate : ( item , options = { } ) => {
1166
+ ToTemporalDate : ( item , options = ObjectCreate ( null ) ) => {
1165
1167
if ( ES . Type ( item ) === 'Object' ) {
1166
1168
if ( ES . IsTemporalDate ( item ) ) return item ;
1167
1169
if ( ES . IsTemporalZonedDateTime ( item ) ) {
@@ -1207,7 +1209,7 @@ export const ES = ObjectAssign({}, ES2020, {
1207
1209
) ) ;
1208
1210
return { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } ;
1209
1211
} ,
1210
- ToTemporalDateTime : ( item , options = { } ) => {
1212
+ ToTemporalDateTime : ( item , options = ObjectCreate ( null ) ) => {
1211
1213
let year , month , day , hour , minute , second , millisecond , microsecond , nanosecond , calendar ;
1212
1214
if ( ES . Type ( item ) === 'Object' ) {
1213
1215
if ( ES . IsTemporalDateTime ( item ) ) return item ;
@@ -1343,7 +1345,7 @@ export const ES = ObjectAssign({}, ES2020, {
1343
1345
const TemporalInstant = GetIntrinsic ( '%Temporal.Instant%' ) ;
1344
1346
return new TemporalInstant ( ns ) ;
1345
1347
} ,
1346
- ToTemporalMonthDay : ( item , options = { } ) => {
1348
+ ToTemporalMonthDay : ( item , options = ObjectCreate ( null ) ) => {
1347
1349
if ( ES . Type ( item ) === 'Object' ) {
1348
1350
if ( ES . IsTemporalMonthDay ( item ) ) return item ;
1349
1351
let calendar , calendarAbsent ;
@@ -1377,7 +1379,8 @@ export const ES = ObjectAssign({}, ES2020, {
1377
1379
return ES . CreateTemporalMonthDay ( month , day , calendar ) ;
1378
1380
}
1379
1381
const result = ES . CreateTemporalMonthDay ( month , day , calendar , referenceISOYear ) ;
1380
- return ES . MonthDayFromFields ( calendar , result , { } ) ;
1382
+ const canonicalOptions = ObjectCreate ( null ) ;
1383
+ return ES . MonthDayFromFields ( calendar , result , canonicalOptions ) ;
1381
1384
} ,
1382
1385
ToTemporalTime : ( item , overflow = 'constrain' ) => {
1383
1386
let hour , minute , second , millisecond , microsecond , nanosecond , calendar ;
@@ -1427,7 +1430,7 @@ export const ES = ObjectAssign({}, ES2020, {
1427
1430
const TemporalPlainTime = GetIntrinsic ( '%Temporal.PlainTime%' ) ;
1428
1431
return new TemporalPlainTime ( hour , minute , second , millisecond , microsecond , nanosecond ) ;
1429
1432
} ,
1430
- ToTemporalYearMonth : ( item , options = { } ) => {
1433
+ ToTemporalYearMonth : ( item , options = ObjectCreate ( null ) ) => {
1431
1434
if ( ES . Type ( item ) === 'Object' ) {
1432
1435
if ( ES . IsTemporalYearMonth ( item ) ) return item ;
1433
1436
const calendar = ES . GetOptionalTemporalCalendar ( item ) ;
@@ -1446,7 +1449,8 @@ export const ES = ObjectAssign({}, ES2020, {
1446
1449
return ES . CreateTemporalYearMonth ( year , month , calendar ) ;
1447
1450
}
1448
1451
const result = ES . CreateTemporalYearMonth ( year , month , calendar , referenceISODay ) ;
1449
- return ES . YearMonthFromFields ( calendar , result , { } ) ;
1452
+ const canonicalOptions = ObjectCreate ( null ) ;
1453
+ return ES . YearMonthFromFields ( calendar , result , canonicalOptions ) ;
1450
1454
} ,
1451
1455
InterpretISODateTimeOffset : (
1452
1456
year ,
@@ -1512,7 +1516,7 @@ export const ES = ObjectAssign({}, ES2020, {
1512
1516
const instant = ES . BuiltinTimeZoneGetInstantFor ( timeZone , dt , disambiguation ) ;
1513
1517
return GetSlot ( instant , EPOCHNANOSECONDS ) ;
1514
1518
} ,
1515
- ToTemporalZonedDateTime : ( item , options = { } ) => {
1519
+ ToTemporalZonedDateTime : ( item , options = ObjectCreate ( null ) ) => {
1516
1520
let year , month , day , hour , minute , second , millisecond , microsecond , nanosecond , timeZone , offset , calendar ;
1517
1521
if ( ES . Type ( item ) === 'Object' ) {
1518
1522
if ( ES . IsTemporalZonedDateTime ( item ) ) return item ;
@@ -2868,14 +2872,12 @@ export const ES = ObjectAssign({}, ES2020, {
2868
2872
const dateAdd = ES . GetMethod ( calendar , 'dateAdd' ) ;
2869
2873
const dateUntil = ES . GetMethod ( calendar , 'dateUntil' ) ;
2870
2874
while ( MathAbs ( years ) > 0 ) {
2871
- const newRelativeTo = ES . CalendarDateAdd ( calendar , relativeTo , oneYear , { } , dateAdd ) ;
2872
- const oneYearMonths = ES . CalendarDateUntil (
2873
- calendar ,
2874
- relativeTo ,
2875
- newRelativeTo ,
2876
- { largestUnit : 'months' } ,
2877
- dateUntil
2878
- ) . months ;
2875
+ const addOptions = ObjectCreate ( null ) ;
2876
+ const newRelativeTo = ES . CalendarDateAdd ( calendar , relativeTo , oneYear , addOptions , dateAdd ) ;
2877
+ const untilOptions = ObjectCreate ( null ) ;
2878
+ untilOptions . largestUnit = 'months' ;
2879
+ const oneYearMonths = ES . CalendarDateUntil ( calendar , relativeTo , newRelativeTo , untilOptions , dateUntil )
2880
+ . months ;
2879
2881
relativeTo = newRelativeTo ;
2880
2882
months += oneYearMonths ;
2881
2883
years -= sign ;
@@ -2972,27 +2974,21 @@ export const ES = ObjectAssign({}, ES2020, {
2972
2974
2973
2975
// balance months up to years
2974
2976
const dateAdd = ES . GetMethod ( calendar , 'dateAdd' ) ;
2975
- newRelativeTo = ES . CalendarDateAdd ( calendar , relativeTo , oneYear , { } , dateAdd ) ;
2977
+ const addOptions = ObjectCreate ( null ) ;
2978
+ newRelativeTo = ES . CalendarDateAdd ( calendar , relativeTo , oneYear , addOptions , dateAdd ) ;
2976
2979
const dateUntil = ES . GetMethod ( calendar , 'dateUntil' ) ;
2977
- let oneYearMonths = ES . CalendarDateUntil (
2978
- calendar ,
2979
- relativeTo ,
2980
- newRelativeTo ,
2981
- { largestUnit : 'months' } ,
2982
- dateUntil
2983
- ) . months ;
2980
+ const untilOptions = ObjectCreate ( null ) ;
2981
+ untilOptions . largestUnit = 'months' ;
2982
+ let oneYearMonths = ES . CalendarDateUntil ( calendar , relativeTo , newRelativeTo , untilOptions , dateUntil ) . months ;
2984
2983
while ( MathAbs ( months ) >= MathAbs ( oneYearMonths ) ) {
2985
2984
months -= oneYearMonths ;
2986
2985
years += sign ;
2987
2986
relativeTo = newRelativeTo ;
2988
- newRelativeTo = ES . CalendarDateAdd ( calendar , relativeTo , oneYear , { } , dateAdd ) ;
2989
- oneYearMonths = ES . CalendarDateUntil (
2990
- calendar ,
2991
- relativeTo ,
2992
- newRelativeTo ,
2993
- { largestUnit : 'months' } ,
2994
- dateUntil
2995
- ) . months ;
2987
+ const addOptions = ObjectCreate ( null ) ;
2988
+ newRelativeTo = ES . CalendarDateAdd ( calendar , relativeTo , oneYear , addOptions , dateAdd ) ;
2989
+ const untilOptions = ObjectCreate ( null ) ;
2990
+ untilOptions . largestUnit = 'months' ;
2991
+ oneYearMonths = ES . CalendarDateUntil ( calendar , relativeTo , newRelativeTo , untilOptions , dateUntil ) . months ;
2996
2992
}
2997
2993
break ;
2998
2994
}
@@ -3320,7 +3316,7 @@ export const ES = ObjectAssign({}, ES2020, {
3320
3316
ns2 ,
3321
3317
calendar ,
3322
3318
largestUnit ,
3323
- options = { }
3319
+ options = ObjectCreate ( null )
3324
3320
) => {
3325
3321
let { deltaDays, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES . DifferenceTime (
3326
3322
h1 ,
@@ -3555,13 +3551,15 @@ export const ES = ObjectAssign({}, ES2020, {
3555
3551
const dateDuration1 = new TemporalDuration ( y1 , mon1 , w1 , d1 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
3556
3552
const dateDuration2 = new TemporalDuration ( y2 , mon2 , w2 , d2 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
3557
3553
const dateAdd = ES . GetMethod ( calendar , 'dateAdd' ) ;
3558
- const intermediate = ES . CalendarDateAdd ( calendar , datePart , dateDuration1 , { } , dateAdd ) ;
3559
- const end = ES . CalendarDateAdd ( calendar , intermediate , dateDuration2 , { } , dateAdd ) ;
3554
+ const firstAddOptions = ObjectCreate ( null ) ;
3555
+ const intermediate = ES . CalendarDateAdd ( calendar , datePart , dateDuration1 , firstAddOptions , dateAdd ) ;
3556
+ const secondAddOptions = ObjectCreate ( null ) ;
3557
+ const end = ES . CalendarDateAdd ( calendar , intermediate , dateDuration2 , secondAddOptions , dateAdd ) ;
3560
3558
3561
3559
const dateLargestUnit = ES . LargerOfTwoTemporalDurationUnits ( 'days' , largestUnit ) ;
3562
- ( { years , months , weeks , days } = ES . CalendarDateUntil ( calendar , datePart , end , {
3563
- largestUnit : dateLargestUnit
3564
- } ) ) ;
3560
+ const differenceOptions = ObjectCreate ( null ) ;
3561
+ differenceOptions . largestUnit = dateLargestUnit ;
3562
+ ( { years , months , weeks , days } = ES . CalendarDateUntil ( calendar , datePart , end , differenceOptions ) ) ;
3565
3563
// Signs of date part and time part may not agree; balance them together
3566
3564
( { days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES . BalanceDuration (
3567
3565
days ,
@@ -3891,7 +3889,8 @@ export const ES = ObjectAssign({}, ES2020, {
3891
3889
) . days ;
3892
3890
} ,
3893
3891
MoveRelativeDate : ( calendar , relativeTo , duration ) => {
3894
- const later = ES . CalendarDateAdd ( calendar , relativeTo , duration , { } ) ;
3892
+ const options = ObjectCreate ( null ) ;
3893
+ const later = ES . CalendarDateAdd ( calendar , relativeTo , duration , options ) ;
3895
3894
const days = ES . DaysUntil ( relativeTo , later ) ;
3896
3895
relativeTo = ES . CreateTemporalDateTime (
3897
3896
GetSlot ( later , ISO_YEAR ) ,
@@ -4104,18 +4103,30 @@ export const ES = ObjectAssign({}, ES2020, {
4104
4103
// relativeTo + years, relativeTo + { years, months, weeks })
4105
4104
const yearsDuration = new TemporalDuration ( years ) ;
4106
4105
const dateAdd = ES . GetMethod ( calendar , 'dateAdd' ) ;
4107
- const yearsLater = ES . CalendarDateAdd ( calendar , relativeTo , yearsDuration , { } , dateAdd ) ;
4106
+ const firstAddOptions = ObjectCreate ( null ) ;
4107
+ const yearsLater = ES . CalendarDateAdd ( calendar , relativeTo , yearsDuration , firstAddOptions , dateAdd ) ;
4108
4108
const yearsMonthsWeeks = new TemporalDuration ( years , months , weeks ) ;
4109
- const yearsMonthsWeeksLater = ES . CalendarDateAdd ( calendar , relativeTo , yearsMonthsWeeks , { } , dateAdd ) ;
4109
+ const secondAddOptions = ObjectCreate ( null ) ;
4110
+ const yearsMonthsWeeksLater = ES . CalendarDateAdd (
4111
+ calendar ,
4112
+ relativeTo ,
4113
+ yearsMonthsWeeks ,
4114
+ secondAddOptions ,
4115
+ dateAdd
4116
+ ) ;
4110
4117
const monthsWeeksInDays = ES . DaysUntil ( yearsLater , yearsMonthsWeeksLater ) ;
4111
4118
relativeTo = yearsLater ;
4112
4119
days += monthsWeeksInDays ;
4113
4120
4114
- const daysLater = ES . CalendarDateAdd ( calendar , relativeTo , { days } , { } , dateAdd ) ;
4115
- const yearsPassed = ES . CalendarDateUntil ( calendar , relativeTo , daysLater , { largestUnit : 'years' } ) . years ;
4121
+ const thirdAddOptions = ObjectCreate ( null ) ;
4122
+ const daysLater = ES . CalendarDateAdd ( calendar , relativeTo , { days } , thirdAddOptions , dateAdd ) ;
4123
+ const untilOptions = ObjectCreate ( null ) ;
4124
+ untilOptions . largestUnit = 'years' ;
4125
+ const yearsPassed = ES . CalendarDateUntil ( calendar , relativeTo , daysLater , untilOptions ) . years ;
4116
4126
years += yearsPassed ;
4117
4127
const oldRelativeTo = relativeTo ;
4118
- relativeTo = ES . CalendarDateAdd ( calendar , relativeTo , { years : yearsPassed } , { } , dateAdd ) ;
4128
+ const fourthAddOptions = ObjectCreate ( null ) ;
4129
+ relativeTo = ES . CalendarDateAdd ( calendar , relativeTo , { years : yearsPassed } , fourthAddOptions , dateAdd ) ;
4119
4130
const daysPassed = ES . DaysUntil ( oldRelativeTo , relativeTo ) ;
4120
4131
days -= daysPassed ;
4121
4132
const oneYear = new TemporalDuration ( days < 0 ? - 1 : 1 ) ;
@@ -4143,9 +4154,17 @@ export const ES = ObjectAssign({}, ES2020, {
4143
4154
// { years, months }, relativeTo + { years, months, weeks })
4144
4155
const yearsMonths = new TemporalDuration ( years , months ) ;
4145
4156
const dateAdd = ES . GetMethod ( calendar , 'dateAdd' ) ;
4146
- const yearsMonthsLater = ES . CalendarDateAdd ( calendar , relativeTo , yearsMonths , { } , dateAdd ) ;
4157
+ const firstAddOptions = ObjectCreate ( null ) ;
4158
+ const yearsMonthsLater = ES . CalendarDateAdd ( calendar , relativeTo , yearsMonths , firstAddOptions , dateAdd ) ;
4147
4159
const yearsMonthsWeeks = new TemporalDuration ( years , months , weeks ) ;
4148
- const yearsMonthsWeeksLater = ES . CalendarDateAdd ( calendar , relativeTo , yearsMonthsWeeks , { } , dateAdd ) ;
4160
+ const secondAddOptions = ObjectCreate ( null ) ;
4161
+ const yearsMonthsWeeksLater = ES . CalendarDateAdd (
4162
+ calendar ,
4163
+ relativeTo ,
4164
+ yearsMonthsWeeks ,
4165
+ secondAddOptions ,
4166
+ dateAdd
4167
+ ) ;
4149
4168
const weeksInDays = ES . DaysUntil ( yearsMonthsLater , yearsMonthsWeeksLater ) ;
4150
4169
relativeTo = yearsMonthsLater ;
4151
4170
days += weeksInDays ;
0 commit comments