@@ -62,7 +62,7 @@ const YEAR_MIN = -271821;
62
62
const YEAR_MAX = 275760 ;
63
63
const BEFORE_FIRST_DST = bigInt ( - 388152 ) . multiply ( 1e13 ) ; // 1847-01-01T00:00:00Z
64
64
65
- export function IsInteger ( value : unknown ) : value is number {
65
+ function IsInteger ( value : unknown ) : value is number {
66
66
if ( typeof value !== 'number' || ! NumberIsFinite ( value ) ) return false ;
67
67
const abs = MathAbs ( value ) ;
68
68
return MathFloor ( abs ) === abs ;
@@ -94,7 +94,7 @@ export function ToNumber(value: unknown): number {
94
94
return NumberCtor ( value ) ;
95
95
}
96
96
97
- export function ToInteger ( value : unknown ) : number {
97
+ function ToInteger ( value : unknown ) : number {
98
98
const num = ToNumber ( value ) ;
99
99
if ( NumberIsNaN ( num ) ) return 0 ;
100
100
const integer = MathTrunc ( num ) ;
@@ -131,7 +131,7 @@ export function ToPositiveInteger(value, property?: string) {
131
131
return value ;
132
132
}
133
133
134
- export function ToIntegerNoFraction ( value ) {
134
+ function ToIntegerNoFraction ( value ) {
135
135
value = ToNumber ( value ) ;
136
136
if ( ! IsInteger ( value ) ) {
137
137
throw new RangeError ( `unsupported fractional value ${ value } ` ) ;
@@ -258,7 +258,7 @@ export function IsTemporalMonthDay(item) {
258
258
export function IsTemporalZonedDateTime ( item ) {
259
259
return HasSlot ( item , EPOCHNANOSECONDS , TIME_ZONE , CALENDAR ) ;
260
260
}
261
- export function TemporalTimeZoneFromString ( stringIdent ) {
261
+ function TemporalTimeZoneFromString ( stringIdent ) {
262
262
let { ianaName, offset, z } = ParseTemporalTimeZoneString ( stringIdent ) ;
263
263
let identifier = ianaName ;
264
264
if ( ! identifier && z ) identifier = 'UTC' ;
@@ -274,13 +274,13 @@ export function TemporalTimeZoneFromString(stringIdent) {
274
274
return result ;
275
275
}
276
276
277
- export function FormatCalendarAnnotation ( id , showCalendar ) {
277
+ function FormatCalendarAnnotation ( id , showCalendar ) {
278
278
if ( showCalendar === 'never' ) return '' ;
279
279
if ( showCalendar === 'auto' && id === 'iso8601' ) return '' ;
280
280
return `[u-ca=${ id } ]` ;
281
281
}
282
282
283
- export function ParseISODateTime ( isoString , { zoneRequired } ) {
283
+ function ParseISODateTime ( isoString , { zoneRequired } ) {
284
284
const regex = zoneRequired ? PARSE . instant : PARSE . datetime ;
285
285
const match = regex . exec ( isoString ) ;
286
286
if ( ! match ) throw new RangeError ( `invalid ISO 8601 string: ${ isoString } ` ) ;
@@ -344,23 +344,23 @@ export function ParseISODateTime(isoString, { zoneRequired }) {
344
344
} ;
345
345
}
346
346
347
- export function ParseTemporalInstantString ( isoString ) {
347
+ function ParseTemporalInstantString ( isoString ) {
348
348
return ParseISODateTime ( isoString , { zoneRequired : true } ) ;
349
349
}
350
350
351
- export function ParseTemporalZonedDateTimeString ( isoString ) {
351
+ function ParseTemporalZonedDateTimeString ( isoString ) {
352
352
return ParseISODateTime ( isoString , { zoneRequired : true } ) ;
353
353
}
354
354
355
- export function ParseTemporalDateTimeString ( isoString ) {
355
+ function ParseTemporalDateTimeString ( isoString ) {
356
356
return ParseISODateTime ( isoString , { zoneRequired : false } ) ;
357
357
}
358
358
359
- export function ParseTemporalDateString ( isoString ) {
359
+ function ParseTemporalDateString ( isoString ) {
360
360
return ParseISODateTime ( isoString , { zoneRequired : false } ) ;
361
361
}
362
362
363
- export function ParseTemporalTimeString ( isoString ) {
363
+ function ParseTemporalTimeString ( isoString ) {
364
364
const match = PARSE . time . exec ( isoString ) ;
365
365
let hour , minute , second , millisecond , microsecond , nanosecond , calendar ;
366
366
if ( match ) {
@@ -381,7 +381,7 @@ export function ParseTemporalTimeString(isoString) {
381
381
return { hour, minute, second, millisecond, microsecond, nanosecond, calendar } ;
382
382
}
383
383
384
- export function ParseTemporalYearMonthString ( isoString ) {
384
+ function ParseTemporalYearMonthString ( isoString ) {
385
385
const match = PARSE . yearmonth . exec ( isoString ) ;
386
386
let year , month , calendar , referenceISODay ;
387
387
if ( match ) {
@@ -396,7 +396,7 @@ export function ParseTemporalYearMonthString(isoString) {
396
396
return { year, month, calendar, referenceISODay } ;
397
397
}
398
398
399
- export function ParseTemporalMonthDayString ( isoString ) {
399
+ function ParseTemporalMonthDayString ( isoString ) {
400
400
const match = PARSE . monthday . exec ( isoString ) ;
401
401
let month , day , calendar , referenceISOYear ;
402
402
if ( match ) {
@@ -408,7 +408,7 @@ export function ParseTemporalMonthDayString(isoString) {
408
408
return { month, day, calendar, referenceISOYear } ;
409
409
}
410
410
411
- export function ParseTemporalTimeZoneString ( stringIdent ) : {
411
+ function ParseTemporalTimeZoneString ( stringIdent ) : {
412
412
ianaName ?: string | undefined ;
413
413
offset ?: string | undefined ;
414
414
z ?: boolean | undefined ;
@@ -431,7 +431,7 @@ export function ParseTemporalTimeZoneString(stringIdent): {
431
431
}
432
432
}
433
433
434
- export function ParseTemporalDurationString ( isoString ) {
434
+ function ParseTemporalDurationString ( isoString ) {
435
435
const match = PARSE . duration . exec ( isoString ) ;
436
436
if ( ! match ) throw new RangeError ( `invalid duration: ${ isoString } ` ) ;
437
437
if ( match . slice ( 2 ) . every ( ( element ) => element === undefined ) ) {
@@ -467,7 +467,7 @@ export function ParseTemporalDurationString(isoString) {
467
467
return { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } ;
468
468
}
469
469
470
- export function ParseTemporalInstant ( isoString ) {
470
+ function ParseTemporalInstant ( isoString ) {
471
471
const { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, offset, z } =
472
472
ParseTemporalInstantString ( isoString ) ;
473
473
@@ -522,7 +522,7 @@ export function RegulateISOYearMonth(year, month, overflow) {
522
522
return { year, month } ;
523
523
}
524
524
525
- export function DurationHandleFractions ( fHours , minutes , fMinutes , seconds , milliseconds , microseconds , nanoseconds ) {
525
+ function DurationHandleFractions ( fHours , minutes , fMinutes , seconds , milliseconds , microseconds , nanoseconds ) {
526
526
if ( fHours !== 0 ) {
527
527
[ minutes , fMinutes , seconds , milliseconds , microseconds , nanoseconds ] . forEach ( ( val ) => {
528
528
if ( val !== 0 ) throw new RangeError ( 'only the smallest unit can be fractional' ) ;
@@ -561,7 +561,7 @@ export function DurationHandleFractions(fHours, minutes, fMinutes, seconds, mill
561
561
return { minutes, seconds, milliseconds, microseconds, nanoseconds } ;
562
562
}
563
563
564
- export function ToTemporalDurationRecord ( item ) {
564
+ function ToTemporalDurationRecord ( item ) {
565
565
if ( IsTemporalDuration ( item ) ) {
566
566
return {
567
567
years : GetSlot ( item , YEARS ) ,
@@ -1722,7 +1722,7 @@ export function ToTemporalCalendar(calendarLike) {
1722
1722
return new TemporalCalendar ( calendar ) ;
1723
1723
}
1724
1724
1725
- export function GetTemporalCalendarWithISODefault ( item ) {
1725
+ function GetTemporalCalendarWithISODefault ( item ) {
1726
1726
if ( HasSlot ( item , CALENDAR ) ) return GetSlot ( item , CALENDAR ) ;
1727
1727
const { calendar } = item ;
1728
1728
if ( calendar === undefined ) return GetISO8601Calendar ( ) ;
@@ -1853,7 +1853,7 @@ export function BuiltinTimeZoneGetInstantFor(timeZone, dateTime, disambiguation)
1853
1853
return DisambiguatePossibleInstants ( possibleInstants , timeZone , dateTime , disambiguation ) ;
1854
1854
}
1855
1855
1856
- export function DisambiguatePossibleInstants ( possibleInstants , timeZone , dateTime , disambiguation ) {
1856
+ function DisambiguatePossibleInstants ( possibleInstants , timeZone , dateTime , disambiguation ) {
1857
1857
const Instant = GetIntrinsic ( '%Temporal.Instant%' ) ;
1858
1858
const numInstants = possibleInstants . length ;
1859
1859
@@ -1978,7 +1978,7 @@ export function DisambiguatePossibleInstants(possibleInstants, timeZone, dateTim
1978
1978
}
1979
1979
}
1980
1980
1981
- export function GetPossibleInstantsFor ( timeZone , dateTime ) {
1981
+ function GetPossibleInstantsFor ( timeZone , dateTime ) {
1982
1982
const possibleInstants = timeZone . getPossibleInstantsFor ( dateTime ) ;
1983
1983
const result = [ ] ;
1984
1984
for ( const instant of possibleInstants ) {
@@ -2262,7 +2262,7 @@ export function GetIANATimeZoneOffsetNanoseconds(epochNanoseconds, id) {
2262
2262
return + utc . minus ( epochNanoseconds ) ;
2263
2263
}
2264
2264
2265
- export function FormatTimeZoneOffsetString ( offsetNanoseconds ) {
2265
+ function FormatTimeZoneOffsetString ( offsetNanoseconds ) {
2266
2266
const sign = offsetNanoseconds < 0 ? '-' : '+' ;
2267
2267
offsetNanoseconds = MathAbs ( offsetNanoseconds ) ;
2268
2268
const nanoseconds = offsetNanoseconds % 1e9 ;
@@ -2299,7 +2299,7 @@ export function GetEpochFromISOParts(year, month, day, hour, minute, second, mil
2299
2299
return ns ;
2300
2300
}
2301
2301
2302
- export function GetISOPartsFromEpoch ( epochNanoseconds ) {
2302
+ function GetISOPartsFromEpoch ( epochNanoseconds ) {
2303
2303
const { quotient, remainder } = bigInt ( epochNanoseconds ) . divmod ( 1e6 ) ;
2304
2304
let epochMilliseconds = + quotient ;
2305
2305
let nanos = + remainder ;
@@ -2509,7 +2509,7 @@ export function DurationSign(y, mon, w, d, h, min, s, ms, µs, ns) {
2509
2509
return 0 ;
2510
2510
}
2511
2511
2512
- export function BalanceISOYearMonth ( year , month ) {
2512
+ function BalanceISOYearMonth ( year , month ) {
2513
2513
if ( ! NumberIsFinite ( year ) || ! NumberIsFinite ( month ) ) throw new RangeError ( 'infinity is out of range' ) ;
2514
2514
month -= 1 ;
2515
2515
year += MathFloor ( month / 12 ) ;
@@ -2519,7 +2519,7 @@ export function BalanceISOYearMonth(year, month) {
2519
2519
return { year, month } ;
2520
2520
}
2521
2521
2522
- export function BalanceISODate ( year , month , day ) {
2522
+ function BalanceISODate ( year , month , day ) {
2523
2523
if ( ! NumberIsFinite ( day ) ) throw new RangeError ( 'infinity is out of range' ) ;
2524
2524
( { year, month } = BalanceISOYearMonth ( year , month ) ) ;
2525
2525
let daysInYear = 0 ;
@@ -2548,7 +2548,7 @@ export function BalanceISODate(year, month, day) {
2548
2548
return { year, month, day } ;
2549
2549
}
2550
2550
2551
- export function BalanceISODateTime ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond ) {
2551
+ function BalanceISODateTime ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond ) {
2552
2552
let deltaDays ;
2553
2553
( { deltaDays, hour, minute, second, millisecond, microsecond, nanosecond } = BalanceTime (
2554
2554
hour ,
@@ -2562,7 +2562,7 @@ export function BalanceISODateTime(year, month, day, hour, minute, second, milli
2562
2562
return { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } ;
2563
2563
}
2564
2564
2565
- export function BalanceTime ( hour , minute , second , millisecond , microsecond , nanosecond ) {
2565
+ function BalanceTime ( hour , minute , second , millisecond , microsecond , nanosecond ) {
2566
2566
if (
2567
2567
! NumberIsFinite ( hour ) ||
2568
2568
! NumberIsFinite ( minute ) ||
@@ -2614,7 +2614,7 @@ export function TotalDurationNanoseconds(
2614
2614
return bigInt ( nanoseconds ) . add ( microseconds . multiply ( 1000 ) ) ;
2615
2615
}
2616
2616
2617
- export function NanosecondsToDays ( nanoseconds , relativeTo ) {
2617
+ function NanosecondsToDays ( nanoseconds , relativeTo ) {
2618
2618
const TemporalInstant = GetIntrinsic ( '%Temporal.Instant%' ) ;
2619
2619
const sign = MathSign ( nanoseconds ) ;
2620
2620
nanoseconds = bigInt ( nanoseconds ) ;
@@ -3000,13 +3000,13 @@ export function CreateNegatedTemporalDuration(duration) {
3000
3000
export function ConstrainToRange ( value , min , max ) {
3001
3001
return MathMin ( max , MathMax ( min , value ) ) ;
3002
3002
}
3003
- export function ConstrainISODate ( year , month , day ?: any ) {
3003
+ function ConstrainISODate ( year , month , day ?: any ) {
3004
3004
month = ConstrainToRange ( month , 1 , 12 ) ;
3005
3005
day = ConstrainToRange ( day , 1 , ISODaysInMonth ( year , month ) ) ;
3006
3006
return { year, month, day } ;
3007
3007
}
3008
3008
3009
- export function ConstrainTime ( hour , minute , second , millisecond , microsecond , nanosecond ) {
3009
+ function ConstrainTime ( hour , minute , second , millisecond , microsecond , nanosecond ) {
3010
3010
hour = ConstrainToRange ( hour , 0 , 23 ) ;
3011
3011
minute = ConstrainToRange ( minute , 0 , 59 ) ;
3012
3012
second = ConstrainToRange ( second , 0 , 59 ) ;
@@ -3020,12 +3020,12 @@ export function RejectToRange(value, min, max) {
3020
3020
if ( value < min || value > max ) throw new RangeError ( `value out of range: ${ min } <= ${ value } <= ${ max } ` ) ;
3021
3021
}
3022
3022
3023
- export function RejectISODate ( year , month , day ) {
3023
+ function RejectISODate ( year , month , day ) {
3024
3024
RejectToRange ( month , 1 , 12 ) ;
3025
3025
RejectToRange ( day , 1 , ISODaysInMonth ( year , month ) ) ;
3026
3026
}
3027
3027
3028
- export function RejectDateRange ( year , month , day ) {
3028
+ function RejectDateRange ( year , month , day ) {
3029
3029
// Noon avoids trouble at edges of DateTime range (excludes midnight)
3030
3030
RejectDateTimeRange ( year , month , day , 12 , 0 , 0 , 0 , 0 , 0 ) ;
3031
3031
}
@@ -3039,12 +3039,12 @@ export function RejectTime(hour, minute, second, millisecond, microsecond, nanos
3039
3039
RejectToRange ( nanosecond , 0 , 999 ) ;
3040
3040
}
3041
3041
3042
- export function RejectDateTime ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond ) {
3042
+ function RejectDateTime ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond ) {
3043
3043
RejectISODate ( year , month , day ) ;
3044
3044
RejectTime ( hour , minute , second , millisecond , microsecond , nanosecond ) ;
3045
3045
}
3046
3046
3047
- export function RejectDateTimeRange ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond ) {
3047
+ function RejectDateTimeRange ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond ) {
3048
3048
RejectToRange ( year , YEAR_MIN , YEAR_MAX ) ;
3049
3049
// Reject any DateTime 24 hours or more outside the Instant range
3050
3050
if (
@@ -3065,7 +3065,7 @@ export function ValidateEpochNanoseconds(epochNanoseconds) {
3065
3065
}
3066
3066
}
3067
3067
3068
- export function RejectYearMonthRange ( year , month ) {
3068
+ function RejectYearMonthRange ( year , month ) {
3069
3069
RejectToRange ( year , YEAR_MIN , YEAR_MAX ) ;
3070
3070
if ( year === YEAR_MIN ) {
3071
3071
RejectToRange ( month , 4 , 12 ) ;
@@ -3074,7 +3074,7 @@ export function RejectYearMonthRange(year, month) {
3074
3074
}
3075
3075
}
3076
3076
3077
- export function RejectDuration ( y , mon , w , d , h , min , s , ms , µs , ns ) {
3077
+ function RejectDuration ( y , mon , w , d , h , min , s , ms , µs , ns ) {
3078
3078
const sign = DurationSign ( y , mon , w , d , h , min , s , ms , µs , ns ) ;
3079
3079
for ( const prop of [ y , mon , w , d , h , min , s , ms , µs , ns ] ) {
3080
3080
if ( ! NumberIsFinite ( prop ) ) throw new RangeError ( 'infinite values not allowed as duration fields' ) ;
@@ -3689,7 +3689,7 @@ export function AddZonedDateTime(
3689
3689
return AddInstant ( GetSlot ( instantIntermediate , EPOCHNANOSECONDS ) , h , min , s , ms , µs , ns ) ;
3690
3690
}
3691
3691
3692
- export function RoundNumberToIncrement ( quantity , increment , mode ) {
3692
+ function RoundNumberToIncrement ( quantity , increment , mode ) {
3693
3693
if ( increment === 1 ) return quantity ;
3694
3694
let { quotient, remainder } = quantity . divmod ( increment ) ;
3695
3695
if ( remainder . equals ( bigInt . zero ) ) return quantity ;
@@ -3809,7 +3809,7 @@ export function RoundTime(
3809
3809
}
3810
3810
}
3811
3811
3812
- export function DaysUntil ( earlier , later ) {
3812
+ function DaysUntil ( earlier , later ) {
3813
3813
return DifferenceISODate (
3814
3814
GetSlot ( earlier , ISO_YEAR ) ,
3815
3815
GetSlot ( earlier , ISO_MONTH ) ,
@@ -3821,7 +3821,7 @@ export function DaysUntil(earlier, later) {
3821
3821
) . days ;
3822
3822
}
3823
3823
3824
- export function MoveRelativeDate ( calendar , relativeTo , duration ) {
3824
+ function MoveRelativeDate ( calendar , relativeTo , duration ) {
3825
3825
const options = ObjectCreate ( null ) ;
3826
3826
const later = CalendarDateAdd ( calendar , relativeTo , duration , options ) ;
3827
3827
const days = DaysUntil ( relativeTo , later ) ;
@@ -4223,7 +4223,7 @@ export function CompareISODate(y1, m1, d1, y2, m2, d2) {
4223
4223
return 0 ;
4224
4224
}
4225
4225
4226
- export function NonNegativeModulo ( x , y ) {
4226
+ function NonNegativeModulo ( x , y ) {
4227
4227
let result = x % y ;
4228
4228
if ( ObjectIs ( result , - 0 ) ) return 0 ;
4229
4229
if ( result < 0 ) result += y ;
@@ -4298,7 +4298,7 @@ export function GetOptionsObject(options) {
4298
4298
throw new TypeError ( `Options parameter must be an object, not ${ options === null ? 'null' : `a ${ typeof options } ` } ` ) ;
4299
4299
}
4300
4300
4301
- export function GetOption ( options , property , allowedValues , fallback ) {
4301
+ function GetOption ( options , property , allowedValues , fallback ) {
4302
4302
let value = options [ property ] ;
4303
4303
if ( value !== undefined ) {
4304
4304
value = ToString ( value ) ;
@@ -4310,7 +4310,7 @@ export function GetOption(options, property, allowedValues, fallback) {
4310
4310
return fallback ;
4311
4311
}
4312
4312
4313
- export function GetNumberOption ( options , property , minimum , maximum , fallback ) {
4313
+ function GetNumberOption ( options , property , minimum , maximum , fallback ) {
4314
4314
let value = options [ property ] ;
4315
4315
if ( value === undefined ) return fallback ;
4316
4316
value = ToNumber ( value ) ;
0 commit comments