@northguild/gmt 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1133 -272
- package/dist/calendar/business/businessDaysBetween.d.ts +37 -0
- package/dist/calendar/business/businessDaysBetween.js +89 -0
- package/dist/calendar/business/index.d.ts +7 -0
- package/dist/calendar/business/index.js +10 -0
- package/dist/calendar/business/mergeCalendars.d.ts +33 -0
- package/dist/calendar/business/mergeCalendars.js +68 -0
- package/dist/calendar/business/nextBusinessDay.d.ts +30 -0
- package/dist/calendar/business/nextBusinessDay.js +39 -0
- package/dist/calendar/business/previousBusinessDay.d.ts +30 -0
- package/dist/calendar/business/previousBusinessDay.js +39 -0
- package/dist/calendar/business/rollDate.d.ts +59 -0
- package/dist/calendar/business/rollDate.js +116 -0
- package/dist/calendar/calculate/bucketRange.d.ts +49 -0
- package/dist/calendar/calculate/bucketRange.js +169 -0
- package/dist/calendar/calculate/floorToZone.d.ts +42 -0
- package/dist/calendar/calculate/floorToZone.js +62 -0
- package/dist/calendar/calculate/getFiscalPeriod.d.ts +64 -0
- package/dist/calendar/calculate/getFiscalPeriod.js +96 -0
- package/dist/calendar/calculate/getIsoWeekDate.d.ts +35 -0
- package/dist/calendar/calculate/getIsoWeekDate.js +41 -0
- package/dist/calendar/calculate/getOrdinalDate.d.ts +25 -0
- package/dist/calendar/calculate/getOrdinalDate.js +28 -0
- package/dist/calendar/calculate/getQuarter.d.ts +36 -0
- package/dist/calendar/calculate/getQuarter.js +64 -0
- package/dist/calendar/calculate/index.d.ts +6 -0
- package/dist/calendar/calculate/index.js +6 -0
- package/dist/calendar/index.d.ts +4 -0
- package/dist/calendar/index.js +5 -0
- package/dist/calendar/validate/index.d.ts +4 -0
- package/dist/calendar/validate/index.js +4 -0
- package/dist/calendar/validate/isValidBusinessCalendar.d.ts +31 -0
- package/dist/calendar/validate/isValidBusinessCalendar.js +40 -0
- package/dist/calendar/validate/isValidFiscalPattern.d.ts +25 -0
- package/dist/calendar/validate/isValidFiscalPattern.js +29 -0
- package/dist/calendar/validate/isValidRollConvention.d.ts +28 -0
- package/dist/calendar/validate/isValidRollConvention.js +38 -0
- package/dist/calendar/validate/isValidZoneBucketUnit.d.ts +31 -0
- package/dist/calendar/validate/isValidZoneBucketUnit.js +39 -0
- package/dist/duration/calculate/durationAs.d.ts +27 -3
- package/dist/duration/calculate/durationAs.js +34 -8
- package/dist/duration/calculate/getDurationUnit.d.ts +5 -2
- package/dist/duration/calculate/getDurationUnit.js +7 -3
- package/dist/duration/compare/compareDurations.d.ts +25 -2
- package/dist/duration/compare/compareDurations.js +31 -7
- package/dist/duration/format/formatDuration.d.ts +14 -5
- package/dist/duration/format/formatDuration.js +47 -11
- package/dist/duration/index.d.ts +1 -0
- package/dist/duration/index.js +2 -0
- package/dist/duration/normalize/normalizeDuration.d.ts +33 -6
- package/dist/duration/normalize/normalizeDuration.js +41 -12
- package/dist/duration/parse/parseDuration.js +4 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/instant/convert/classifyLocal.d.ts +50 -0
- package/dist/instant/convert/classifyLocal.js +60 -0
- package/dist/instant/convert/fromOffsetInstant.d.ts +47 -0
- package/dist/instant/convert/fromOffsetInstant.js +91 -0
- package/dist/instant/convert/index.d.ts +4 -0
- package/dist/instant/convert/index.js +4 -0
- package/dist/instant/convert/resolveLocal.d.ts +40 -0
- package/dist/instant/convert/resolveLocal.js +76 -0
- package/dist/instant/convert/toOffsetInstant.d.ts +96 -0
- package/dist/instant/convert/toOffsetInstant.js +162 -0
- package/dist/instant/index.d.ts +2 -0
- package/dist/instant/index.js +3 -0
- package/dist/intermodal/calculate/billingTimeline.d.ts +94 -0
- package/dist/intermodal/calculate/billingTimeline.js +168 -0
- package/dist/intermodal/calculate/chargeableDays.d.ts +98 -0
- package/dist/intermodal/calculate/chargeableDays.js +101 -0
- package/dist/intermodal/calculate/demurrageClock.d.ts +93 -0
- package/dist/intermodal/calculate/demurrageClock.js +140 -0
- package/dist/intermodal/calculate/freeTimeExpiry.d.ts +66 -0
- package/dist/intermodal/calculate/freeTimeExpiry.js +82 -0
- package/dist/intermodal/calculate/index.d.ts +4 -0
- package/dist/intermodal/calculate/index.js +4 -0
- package/dist/intermodal/index.d.ts +2 -0
- package/dist/intermodal/index.js +3 -0
- package/dist/internal/adjustZonedBusinessDays.js +9 -7
- package/dist/internal/businessCalendar.d.ts +46 -0
- package/dist/internal/businessCalendar.js +230 -0
- package/dist/internal/businessDayValues.d.ts +20 -0
- package/dist/internal/businessDayValues.js +54 -0
- package/dist/internal/calendarDatePairPolicy.d.ts +10 -12
- package/dist/internal/calendarDatePairPolicy.js +13 -19
- package/dist/internal/calendarDateString.d.ts +32 -58
- package/dist/internal/calendarDateString.js +51 -93
- package/dist/internal/calendarSystemIds.d.ts +26 -2
- package/dist/internal/calendarSystemIds.js +57 -51
- package/dist/internal/calendarValueOfDate.d.ts +10 -12
- package/dist/internal/calendarValueOfDate.js +22 -20
- package/dist/internal/calendarValueOfZoned.d.ts +14 -17
- package/dist/internal/calendarValueOfZoned.js +25 -25
- package/dist/internal/calendarZonedPairPolicy.d.ts +11 -18
- package/dist/internal/calendarZonedPairPolicy.js +14 -25
- package/dist/internal/calendarZonedString.d.ts +41 -65
- package/dist/internal/calendarZonedString.js +52 -101
- package/dist/internal/compareUnixEpochs.d.ts +14 -0
- package/dist/internal/compareUnixEpochs.js +25 -0
- package/dist/internal/dateTimeUnitHelpers.d.ts +18 -0
- package/dist/internal/dateTimeUnitHelpers.js +27 -0
- package/dist/internal/dateUnitHelpers.d.ts +39 -1
- package/dist/internal/dateUnitHelpers.js +73 -11
- package/dist/internal/defaultFractionalDigits.d.ts +14 -0
- package/dist/internal/defaultFractionalDigits.js +23 -0
- package/dist/internal/differenceRecord.d.ts +32 -0
- package/dist/internal/differenceRecord.js +79 -0
- package/dist/internal/divisionBoundary.d.ts +19 -0
- package/dist/internal/divisionBoundary.js +23 -0
- package/dist/internal/durationUntilString.d.ts +1 -1
- package/dist/internal/durationUntilString.js +10 -2
- package/dist/internal/englishCalendarNames.d.ts +11 -0
- package/dist/internal/englishCalendarNames.js +21 -1
- package/dist/internal/epochNanoseconds.d.ts +27 -0
- package/dist/internal/epochNanoseconds.js +31 -0
- package/dist/internal/fiscalCalendar.d.ts +36 -0
- package/dist/internal/fiscalCalendar.js +86 -0
- package/dist/internal/floorDivide.d.ts +15 -0
- package/dist/internal/floorDivide.js +18 -0
- package/dist/internal/foreignEpochs.d.ts +134 -0
- package/dist/internal/foreignEpochs.js +139 -0
- package/dist/internal/formatCalendarDays.d.ts +28 -0
- package/dist/internal/formatCalendarDays.js +49 -0
- package/dist/internal/formatDateInCalendar.d.ts +14 -39
- package/dist/internal/formatDateInCalendar.js +16 -47
- package/dist/internal/formatRelativeDuration.d.ts +27 -0
- package/dist/internal/formatRelativeDuration.js +45 -0
- package/dist/internal/freeTimeLedger.d.ts +93 -0
- package/dist/internal/freeTimeLedger.js +262 -0
- package/dist/internal/getLocaleFirstDayOfWeek.d.ts +9 -6
- package/dist/internal/getLocaleFirstDayOfWeek.js +9 -10
- package/dist/internal/getLocaleWeekYearBounds.d.ts +17 -9
- package/dist/internal/getLocaleWeekYearBounds.js +45 -26
- package/dist/internal/getLocaleWeekendDays.d.ts +9 -18
- package/dist/internal/getLocaleWeekendDays.js +9 -5
- package/dist/internal/halfOpenIntervals.d.ts +102 -0
- package/dist/internal/halfOpenIntervals.js +180 -0
- package/dist/internal/hasCalendarAnnotation.d.ts +20 -20
- package/dist/internal/hasCalendarAnnotation.js +23 -21
- package/dist/internal/hourDurationString.d.ts +16 -0
- package/dist/internal/hourDurationString.js +47 -0
- package/dist/internal/httpDateFields.d.ts +24 -0
- package/dist/internal/httpDateFields.js +86 -0
- package/dist/internal/index.d.ts +30 -9
- package/dist/internal/index.js +30 -9
- package/dist/internal/instantFormatOptions.d.ts +43 -0
- package/dist/internal/instantFormatOptions.js +99 -0
- package/dist/internal/instantIntervalText.d.ts +20 -0
- package/dist/internal/instantIntervalText.js +25 -0
- package/dist/internal/instantNanoseconds.d.ts +25 -0
- package/dist/internal/instantNanoseconds.js +41 -0
- package/dist/internal/intervalCountHelpers.d.ts +16 -10
- package/dist/internal/intervalCountHelpers.js +1 -31
- package/dist/internal/intervalNanoseconds.d.ts +47 -0
- package/dist/internal/intervalNanoseconds.js +86 -0
- package/dist/internal/isObject.d.ts +26 -0
- package/dist/internal/isObject.js +30 -0
- package/dist/internal/isoStringBody.d.ts +66 -0
- package/dist/internal/isoStringBody.js +105 -0
- package/dist/internal/joinDateTimeConnector.d.ts +1 -1
- package/dist/internal/localeWeekInfo.d.ts +34 -0
- package/dist/internal/localeWeekInfo.js +27 -0
- package/dist/internal/maxPieces.d.ts +41 -0
- package/dist/internal/maxPieces.js +53 -0
- package/dist/internal/measureNearRangeEnd.d.ts +26 -0
- package/dist/internal/measureNearRangeEnd.js +47 -0
- package/dist/internal/monthGridWeekRow.d.ts +4 -1
- package/dist/internal/monthGridWeekRow.js +3 -0
- package/dist/internal/normalizeTimeZone.d.ts +17 -10
- package/dist/internal/normalizeTimeZone.js +25 -15
- package/dist/internal/patternToken.d.ts +2 -1
- package/dist/internal/patternToken.js +10 -4
- package/dist/internal/plainDateAdd.d.ts +20 -0
- package/dist/internal/plainDateAdd.js +42 -0
- package/dist/internal/plainDateUntil.d.ts +21 -0
- package/dist/internal/plainDateUntil.js +48 -0
- package/dist/internal/plainFormatOptions.d.ts +59 -0
- package/dist/internal/plainFormatOptions.js +165 -0
- package/dist/internal/resolveDateTimeUnit.d.ts +4 -1
- package/dist/internal/resolveDateTimeUnit.js +2 -12
- package/dist/internal/resolveDurationRelativeTo.d.ts +28 -22
- package/dist/internal/resolveDurationRelativeTo.js +69 -25
- package/dist/internal/resolveDurationUnit.d.ts +4 -1
- package/dist/internal/resolveDurationUnit.js +2 -11
- package/dist/internal/resolveLocale.d.ts +37 -0
- package/dist/internal/resolveLocale.js +59 -0
- package/dist/internal/resolveManualRoundingOptions.d.ts +23 -0
- package/dist/internal/resolveManualRoundingOptions.js +39 -0
- package/dist/internal/resolveMinimalDaysInFirstWeek.d.ts +19 -0
- package/dist/internal/resolveMinimalDaysInFirstWeek.js +28 -0
- package/dist/internal/resolveOverflow.d.ts +6 -0
- package/dist/internal/resolveOverflow.js +7 -1
- package/dist/internal/resolveReadingTimeZone.d.ts +11 -0
- package/dist/internal/resolveReadingTimeZone.js +18 -0
- package/dist/internal/resolveUnixIntervalPair.d.ts +30 -0
- package/dist/internal/resolveUnixIntervalPair.js +53 -0
- package/dist/internal/resolveWeekStartsOn.d.ts +12 -0
- package/dist/internal/resolveWeekStartsOn.js +18 -0
- package/dist/internal/rfc5322DateTime.d.ts +26 -0
- package/dist/internal/rfc5322DateTime.js +176 -0
- package/dist/internal/splitStep.d.ts +81 -0
- package/dist/internal/splitStep.js +182 -0
- package/dist/internal/startOrEndOfUnix.d.ts +26 -0
- package/dist/internal/startOrEndOfUnix.js +47 -0
- package/dist/{utc/calculate → internal}/startOrEndOfUtc.d.ts +8 -4
- package/dist/{utc/calculate → internal}/startOrEndOfUtc.js +30 -26
- package/dist/internal/startOrEndOfZoned.d.ts +22 -0
- package/dist/internal/startOrEndOfZoned.js +49 -0
- package/dist/internal/temporalCompat/calendarDateArithmetic.d.ts +33 -0
- package/dist/internal/temporalCompat/calendarDateArithmetic.js +199 -0
- package/dist/internal/temporalCompat/calendarDateFromFields.d.ts +36 -0
- package/dist/internal/temporalCompat/calendarDateFromFields.js +120 -0
- package/dist/internal/temporalCompat/calendarFields.d.ts +25 -0
- package/dist/internal/temporalCompat/calendarFields.js +131 -0
- package/dist/internal/temporalCompat/capabilities.d.ts +28 -0
- package/dist/internal/temporalCompat/capabilities.js +74 -0
- package/dist/internal/temporalCompat/fieldSearch.d.ts +21 -0
- package/dist/internal/temporalCompat/fieldSearch.js +83 -0
- package/dist/internal/temporalCompat/fixedDay.d.ts +25 -0
- package/dist/internal/temporalCompat/fixedDay.js +45 -0
- package/dist/internal/temporalCompat/hebrewArithmetic.d.ts +19 -0
- package/dist/internal/temporalCompat/hebrewArithmetic.js +150 -0
- package/dist/internal/temporalCompat/index.d.ts +4 -0
- package/dist/internal/temporalCompat/index.js +5 -0
- package/dist/internal/temporalCompat/indianArithmetic.d.ts +16 -0
- package/dist/internal/temporalCompat/indianArithmetic.js +87 -0
- package/dist/internal/temporalCompat/largeMonthSpan.d.ts +19 -0
- package/dist/internal/temporalCompat/largeMonthSpan.js +199 -0
- package/dist/internal/temporalCompat/nonIsoArithmetic.d.ts +59 -0
- package/dist/internal/temporalCompat/nonIsoArithmetic.js +220 -0
- package/dist/internal/temporalCompat/readArithmeticModel.d.ts +3 -0
- package/dist/internal/temporalCompat/readArithmeticModel.js +284 -0
- package/dist/internal/temporalCompat/repros.d.ts +31 -0
- package/dist/internal/temporalCompat/repros.js +556 -0
- package/dist/internal/toInstantFromUtc.d.ts +10 -0
- package/dist/internal/toInstantFromUtc.js +19 -0
- package/dist/internal/unixEpochValue.d.ts +166 -0
- package/dist/internal/unixEpochValue.js +245 -0
- package/dist/internal/unixFormatReference.d.ts +18 -0
- package/dist/internal/unixFormatReference.js +44 -0
- package/dist/internal/unixZonedDateTime.d.ts +22 -0
- package/dist/internal/unixZonedDateTime.js +32 -0
- package/dist/internal/utcOffsetString.d.ts +39 -0
- package/dist/internal/utcOffsetString.js +75 -0
- package/dist/internal/utcZonedDateTime.d.ts +16 -0
- package/dist/internal/utcZonedDateTime.js +28 -0
- package/dist/internal/wallClockAtOffset.d.ts +22 -0
- package/dist/internal/wallClockAtOffset.js +26 -0
- package/dist/internal/zonedBucket.d.ts +91 -0
- package/dist/internal/zonedBucket.js +441 -0
- package/dist/internal/zonedFormatReference.d.ts +15 -0
- package/dist/internal/zonedFormatReference.js +24 -0
- package/dist/internal/zonedLocalDates.d.ts +15 -0
- package/dist/internal/zonedLocalDates.js +58 -0
- package/dist/internal/zonedNowUnitValue.d.ts +24 -0
- package/dist/internal/zonedNowUnitValue.js +58 -0
- package/dist/internal/zonedWallClock.d.ts +84 -0
- package/dist/internal/zonedWallClock.js +427 -0
- package/dist/internal/zonedWallClockDifference.d.ts +92 -0
- package/dist/internal/zonedWallClockDifference.js +1174 -0
- package/dist/internal/zonedWallClockOperations.d.ts +132 -0
- package/dist/internal/zonedWallClockOperations.js +553 -0
- package/dist/internal/zonelessCalendarDate.d.ts +12 -0
- package/dist/internal/zonelessCalendarDate.js +22 -0
- package/dist/interval/calculate/clampInterval.d.ts +22 -0
- package/dist/interval/calculate/clampInterval.js +31 -0
- package/dist/interval/calculate/index.d.ts +6 -0
- package/dist/interval/calculate/index.js +6 -0
- package/dist/interval/calculate/intersectIntervals.d.ts +23 -0
- package/dist/interval/calculate/intersectIntervals.js +43 -0
- package/dist/interval/calculate/mergeIntervals.d.ts +28 -0
- package/dist/interval/calculate/mergeIntervals.js +44 -0
- package/dist/interval/calculate/splitIntervalAt.d.ts +28 -0
- package/dist/interval/calculate/splitIntervalAt.js +63 -0
- package/dist/interval/calculate/subtractIntervals.d.ts +31 -0
- package/dist/interval/calculate/subtractIntervals.js +64 -0
- package/dist/interval/calculate/sumIntervals.d.ts +26 -0
- package/dist/interval/calculate/sumIntervals.js +40 -0
- package/dist/interval/compare/index.d.ts +2 -0
- package/dist/interval/compare/index.js +2 -0
- package/dist/interval/compare/intervalContains.d.ts +25 -0
- package/dist/interval/compare/intervalContains.js +39 -0
- package/dist/interval/compare/intervalsOverlap.d.ts +28 -0
- package/dist/interval/compare/intervalsOverlap.js +42 -0
- package/dist/interval/index.d.ts +4 -0
- package/dist/interval/index.js +5 -0
- package/dist/interval/validate/index.d.ts +1 -0
- package/dist/interval/validate/index.js +1 -0
- package/dist/interval/validate/isValidInterval.d.ts +29 -0
- package/dist/interval/validate/isValidInterval.js +38 -0
- package/dist/plain/calculate/addBusinessDays.d.ts +26 -9
- package/dist/plain/calculate/addBusinessDays.js +29 -21
- package/dist/plain/calculate/addDate.d.ts +9 -8
- package/dist/plain/calculate/addDate.js +35 -22
- package/dist/plain/calculate/addDateTime.js +24 -10
- package/dist/plain/calculate/addTime.d.ts +5 -8
- package/dist/plain/calculate/addTime.js +23 -16
- package/dist/plain/calculate/clampDate.js +3 -3
- package/dist/plain/calculate/closestDateTo.d.ts +11 -7
- package/dist/plain/calculate/closestDateTo.js +36 -24
- package/dist/plain/calculate/cycleDate.d.ts +1 -1
- package/dist/plain/calculate/cycleDate.js +10 -3
- package/dist/plain/calculate/cycleDateTime.d.ts +1 -1
- package/dist/plain/calculate/cycleDateTime.js +10 -3
- package/dist/plain/calculate/cycleTime.d.ts +6 -8
- package/dist/plain/calculate/cycleTime.js +15 -9
- package/dist/plain/calculate/diffDate.d.ts +31 -14
- package/dist/plain/calculate/diffDate.js +73 -38
- package/dist/plain/calculate/diffDateAsDuration.d.ts +13 -8
- package/dist/plain/calculate/diffDateAsDuration.js +22 -9
- package/dist/plain/calculate/diffDateTime.d.ts +17 -5
- package/dist/plain/calculate/diffDateTime.js +67 -28
- package/dist/plain/calculate/diffDateTimeAsDuration.d.ts +2 -2
- package/dist/plain/calculate/diffDateTimeAsDuration.js +10 -3
- package/dist/plain/calculate/diffTime.d.ts +18 -5
- package/dist/plain/calculate/diffTime.js +68 -27
- package/dist/plain/calculate/endOfDate.d.ts +10 -2
- package/dist/plain/calculate/endOfDate.js +52 -27
- package/dist/plain/calculate/endOfDateTime.d.ts +17 -2
- package/dist/plain/calculate/endOfDateTime.js +126 -103
- package/dist/plain/calculate/endOfTime.d.ts +16 -2
- package/dist/plain/calculate/endOfTime.js +77 -59
- package/dist/plain/calculate/getLargestDateDurationUnit.d.ts +13 -5
- package/dist/plain/calculate/getLargestDateDurationUnit.js +26 -10
- package/dist/plain/calculate/getLargestDateTimeDurationUnit.d.ts +13 -6
- package/dist/plain/calculate/getLargestDateTimeDurationUnit.js +37 -22
- package/dist/plain/calculate/getLargestTimeDurationUnit.d.ts +13 -6
- package/dist/plain/calculate/getLargestTimeDurationUnit.js +33 -18
- package/dist/plain/calculate/getLocaleDayOfWeek.d.ts +8 -4
- package/dist/plain/calculate/getLocaleDayOfWeek.js +8 -3
- package/dist/plain/calculate/getLocaleEndOfWeek.d.ts +8 -4
- package/dist/plain/calculate/getLocaleEndOfWeek.js +8 -3
- package/dist/plain/calculate/getLocaleStartOfWeek.d.ts +8 -4
- package/dist/plain/calculate/getLocaleStartOfWeek.js +8 -3
- package/dist/plain/calculate/getLocaleWeekYear.d.ts +29 -19
- package/dist/plain/calculate/getLocaleWeekYear.js +48 -28
- package/dist/plain/calculate/getWeekNumber.d.ts +21 -2
- package/dist/plain/calculate/getWeekNumber.js +33 -12
- package/dist/plain/calculate/getWeekOfMonth.d.ts +4 -2
- package/dist/plain/calculate/getWeekOfMonth.js +8 -3
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.d.ts +25 -14
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.js +45 -25
- package/dist/plain/calculate/getWeeksInMonth.d.ts +4 -2
- package/dist/plain/calculate/getWeeksInMonth.js +8 -3
- package/dist/plain/calculate/getWeeksInYear.d.ts +5 -4
- package/dist/plain/calculate/getWeeksInYear.js +9 -14
- package/dist/plain/calculate/maxDate.js +19 -12
- package/dist/plain/calculate/maxDateTime.js +19 -12
- package/dist/plain/calculate/maxTime.js +19 -12
- package/dist/plain/calculate/minDate.js +19 -12
- package/dist/plain/calculate/minDateTime.js +19 -12
- package/dist/plain/calculate/minTime.js +19 -12
- package/dist/plain/calculate/nextWeekday.js +5 -0
- package/dist/plain/calculate/previousWeekday.js +5 -0
- package/dist/plain/calculate/roundDate.d.ts +23 -5
- package/dist/plain/calculate/roundDate.js +88 -46
- package/dist/plain/calculate/roundDateTime.d.ts +27 -3
- package/dist/plain/calculate/roundDateTime.js +128 -69
- package/dist/plain/calculate/roundTime.d.ts +8 -1
- package/dist/plain/calculate/roundTime.js +32 -17
- package/dist/plain/calculate/setDate.js +4 -0
- package/dist/plain/calculate/setDateTime.js +4 -0
- package/dist/plain/calculate/setTime.d.ts +1 -1
- package/dist/plain/calculate/setTime.js +5 -1
- package/dist/plain/calculate/sortDateTimes.js +17 -10
- package/dist/plain/calculate/sortDates.js +17 -10
- package/dist/plain/calculate/sortTimes.js +17 -10
- package/dist/plain/calculate/startOfDate.d.ts +7 -2
- package/dist/plain/calculate/startOfDate.js +52 -27
- package/dist/plain/calculate/startOfDateTime.d.ts +5 -2
- package/dist/plain/calculate/startOfDateTime.js +81 -62
- package/dist/plain/calculate/startOfQuarterForDateTime.d.ts +2 -0
- package/dist/plain/calculate/startOfQuarterForDateTime.js +12 -1
- package/dist/plain/calculate/startOfTime.d.ts +15 -2
- package/dist/plain/calculate/startOfTime.js +33 -37
- package/dist/plain/calculate/subtractBusinessDays.d.ts +25 -10
- package/dist/plain/calculate/subtractBusinessDays.js +28 -22
- package/dist/plain/calculate/subtractDate.d.ts +8 -7
- package/dist/plain/calculate/subtractDate.js +35 -21
- package/dist/plain/calculate/subtractDateTime.js +24 -10
- package/dist/plain/calculate/subtractTime.d.ts +5 -8
- package/dist/plain/calculate/subtractTime.js +23 -16
- package/dist/plain/chop/index.d.ts +0 -1
- package/dist/plain/chop/index.js +0 -1
- package/dist/plain/compare/areDateTimesEqualBy.d.ts +10 -5
- package/dist/plain/compare/areDateTimesEqualBy.js +35 -10
- package/dist/plain/compare/areDatesEqualBy.d.ts +10 -3
- package/dist/plain/compare/areDatesEqualBy.js +41 -14
- package/dist/plain/compare/isBetweenDate.js +32 -16
- package/dist/plain/compare/isBetweenDateTime.js +34 -18
- package/dist/plain/compare/isBetweenTime.js +32 -16
- package/dist/plain/compare/isBusinessDay.d.ts +25 -11
- package/dist/plain/compare/isBusinessDay.js +36 -15
- package/dist/plain/compare/isThisUnit.d.ts +13 -4
- package/dist/plain/compare/isThisUnit.js +33 -13
- package/dist/plain/compare/isWeekend.d.ts +8 -4
- package/dist/plain/compare/isWeekend.js +7 -3
- package/dist/plain/convert/convertDateToCalendar.d.ts +34 -33
- package/dist/plain/convert/convertDateToCalendar.js +41 -40
- package/dist/plain/format/formatCalendar.d.ts +12 -6
- package/dist/plain/format/formatCalendar.js +47 -25
- package/dist/plain/format/formatDate.d.ts +21 -4
- package/dist/plain/format/formatDate.js +37 -5
- package/dist/plain/format/formatDateRange.d.ts +17 -4
- package/dist/plain/format/formatDateRange.js +29 -5
- package/dist/plain/format/formatDateTime.d.ts +22 -4
- package/dist/plain/format/formatDateTime.js +31 -5
- package/dist/plain/format/formatDateTimeRange.d.ts +20 -4
- package/dist/plain/format/formatDateTimeRange.js +29 -5
- package/dist/plain/format/formatDateTimeToParts.d.ts +32 -6
- package/dist/plain/format/formatDateTimeToParts.js +40 -14
- package/dist/plain/format/formatDateToParts.d.ts +24 -3
- package/dist/plain/format/formatDateToParts.js +36 -11
- package/dist/plain/format/formatRelativeDate.d.ts +7 -3
- package/dist/plain/format/formatRelativeDate.js +39 -24
- package/dist/plain/format/formatRelativeDateTime.d.ts +15 -6
- package/dist/plain/format/formatRelativeDateTime.js +35 -33
- package/dist/plain/format/formatRelativeTime.d.ts +8 -4
- package/dist/plain/format/formatRelativeTime.js +36 -21
- package/dist/plain/format/formatSql.d.ts +15 -10
- package/dist/plain/format/formatSql.js +20 -11
- package/dist/plain/format/formatTime.d.ts +18 -4
- package/dist/plain/format/formatTime.js +32 -5
- package/dist/plain/get/getNowUnit.d.ts +3 -0
- package/dist/plain/get/getNowUnit.js +14 -29
- package/dist/plain/index.js +1 -1
- package/dist/plain/interval/intervalAbutsDate.d.ts +12 -7
- package/dist/plain/interval/intervalAbutsDate.js +15 -19
- package/dist/plain/interval/intervalAbutsDateTime.d.ts +9 -7
- package/dist/plain/interval/intervalAbutsDateTime.js +17 -23
- package/dist/plain/interval/intervalAbutsTime.d.ts +11 -5
- package/dist/plain/interval/intervalAbutsTime.js +19 -21
- package/dist/plain/interval/intervalContainsDate.d.ts +17 -10
- package/dist/plain/interval/intervalContainsDate.js +20 -15
- package/dist/plain/interval/intervalContainsDateTime.d.ts +16 -11
- package/dist/plain/interval/intervalContainsDateTime.js +24 -20
- package/dist/plain/interval/intervalContainsTime.d.ts +20 -10
- package/dist/plain/interval/intervalContainsTime.js +28 -19
- package/dist/plain/interval/intervalCountDate.d.ts +13 -8
- package/dist/plain/interval/intervalCountDate.js +46 -14
- package/dist/plain/interval/intervalCountDateTime.d.ts +6 -4
- package/dist/plain/interval/intervalCountDateTime.js +63 -18
- package/dist/plain/interval/intervalCountTime.d.ts +3 -4
- package/dist/plain/interval/intervalCountTime.js +9 -9
- package/dist/plain/interval/intervalDifferenceDate.d.ts +13 -6
- package/dist/plain/interval/intervalDifferenceDate.js +19 -32
- package/dist/plain/interval/intervalDifferenceDateTime.d.ts +10 -4
- package/dist/plain/interval/intervalDifferenceDateTime.js +21 -27
- package/dist/plain/interval/intervalDifferenceTime.d.ts +11 -4
- package/dist/plain/interval/intervalDifferenceTime.js +22 -27
- package/dist/plain/interval/intervalDivideEquallyDate.d.ts +16 -4
- package/dist/plain/interval/intervalDivideEquallyDate.js +57 -33
- package/dist/plain/interval/intervalDivideEquallyDateTime.d.ts +16 -4
- package/dist/plain/interval/intervalDivideEquallyDateTime.js +67 -31
- package/dist/plain/interval/intervalDivideEquallyTime.d.ts +16 -4
- package/dist/plain/interval/intervalDivideEquallyTime.js +58 -31
- package/dist/plain/interval/intervalEngulfsDate.d.ts +16 -9
- package/dist/plain/interval/intervalEngulfsDate.js +19 -12
- package/dist/plain/interval/intervalEngulfsDateTime.d.ts +16 -11
- package/dist/plain/interval/intervalEngulfsDateTime.js +24 -18
- package/dist/plain/interval/intervalEngulfsTime.d.ts +18 -8
- package/dist/plain/interval/intervalEngulfsTime.js +26 -15
- package/dist/plain/interval/intervalFromDurationDate.d.ts +5 -4
- package/dist/plain/interval/intervalFromDurationDate.js +11 -8
- package/dist/plain/interval/intervalFromDurationDateTime.js +4 -0
- package/dist/plain/interval/intervalFromDurationTime.d.ts +10 -12
- package/dist/plain/interval/intervalFromDurationTime.js +28 -17
- package/dist/plain/interval/intervalIntersectionDate.d.ts +9 -4
- package/dist/plain/interval/intervalIntersectionDate.js +14 -9
- package/dist/plain/interval/intervalIntersectionDateTime.d.ts +9 -4
- package/dist/plain/interval/intervalIntersectionDateTime.js +19 -13
- package/dist/plain/interval/intervalIntersectionTime.d.ts +7 -3
- package/dist/plain/interval/intervalIntersectionTime.js +17 -12
- package/dist/plain/interval/intervalLengthDate.d.ts +9 -6
- package/dist/plain/interval/intervalLengthDate.js +40 -8
- package/dist/plain/interval/intervalLengthDateTime.js +2 -2
- package/dist/plain/interval/intervalOverlappingDaysDate.d.ts +16 -17
- package/dist/plain/interval/intervalOverlappingDaysDate.js +30 -30
- package/dist/plain/interval/intervalOverlappingDaysDateTime.d.ts +7 -12
- package/dist/plain/interval/intervalOverlappingDaysDateTime.js +24 -24
- package/dist/plain/interval/intervalSplitAtDate.d.ts +10 -5
- package/dist/plain/interval/intervalSplitAtDate.js +48 -36
- package/dist/plain/interval/intervalSplitAtDateTime.d.ts +9 -4
- package/dist/plain/interval/intervalSplitAtDateTime.js +44 -32
- package/dist/plain/interval/intervalSplitAtTime.d.ts +9 -4
- package/dist/plain/interval/intervalSplitAtTime.js +44 -32
- package/dist/plain/interval/intervalUnionDate.d.ts +14 -6
- package/dist/plain/interval/intervalUnionDate.js +19 -11
- package/dist/plain/interval/intervalUnionDateTime.d.ts +12 -5
- package/dist/plain/interval/intervalUnionDateTime.js +22 -14
- package/dist/plain/interval/intervalUnionTime.d.ts +10 -3
- package/dist/plain/interval/intervalUnionTime.js +20 -12
- package/dist/plain/interval/intervalXorAllDate.d.ts +11 -10
- package/dist/plain/interval/intervalXorAllDate.js +37 -59
- package/dist/plain/interval/intervalXorAllDateTime.d.ts +7 -5
- package/dist/plain/interval/intervalXorAllDateTime.js +28 -48
- package/dist/plain/interval/intervalXorAllTime.d.ts +8 -4
- package/dist/plain/interval/intervalXorAllTime.js +29 -47
- package/dist/plain/interval/intervalXorDate.d.ts +10 -9
- package/dist/plain/interval/intervalXorDate.js +19 -54
- package/dist/plain/interval/intervalXorDateTime.d.ts +9 -7
- package/dist/plain/interval/intervalXorDateTime.js +23 -50
- package/dist/plain/interval/intervalXorTime.d.ts +8 -7
- package/dist/plain/interval/intervalXorTime.js +22 -50
- package/dist/plain/interval/intervalsOverlapDate.d.ts +14 -7
- package/dist/plain/interval/intervalsOverlapDate.js +17 -10
- package/dist/plain/interval/intervalsOverlapDateTime.d.ts +12 -7
- package/dist/plain/interval/intervalsOverlapDateTime.js +20 -14
- package/dist/plain/interval/intervalsOverlapTime.d.ts +10 -5
- package/dist/plain/interval/intervalsOverlapTime.js +18 -12
- package/dist/plain/interval/mergeIntervalsDate.d.ts +9 -5
- package/dist/plain/interval/mergeIntervalsDate.js +37 -38
- package/dist/plain/interval/mergeIntervalsDateTime.d.ts +7 -3
- package/dist/plain/interval/mergeIntervalsDateTime.js +31 -32
- package/dist/plain/interval/mergeIntervalsTime.d.ts +7 -3
- package/dist/plain/interval/mergeIntervalsTime.js +31 -31
- package/dist/plain/interval/splitIntervalByUnitDate.d.ts +26 -6
- package/dist/plain/interval/splitIntervalByUnitDate.js +76 -43
- package/dist/plain/interval/splitIntervalByUnitDateTime.d.ts +22 -2
- package/dist/plain/interval/splitIntervalByUnitDateTime.js +65 -39
- package/dist/plain/interval/splitIntervalByUnitTime.d.ts +18 -2
- package/dist/plain/interval/splitIntervalByUnitTime.js +76 -39
- package/dist/plain/interval/validate/isValidDateInterval.d.ts +4 -2
- package/dist/plain/interval/validate/isValidDateInterval.js +4 -2
- package/dist/plain/interval/validate/isValidDateTimeInterval.d.ts +5 -0
- package/dist/plain/interval/validate/isValidDateTimeInterval.js +7 -2
- package/dist/plain/interval/validate/isValidTimeInterval.d.ts +5 -0
- package/dist/plain/interval/validate/isValidTimeInterval.js +8 -18
- package/dist/plain/locale/getLocaleEraNames.d.ts +14 -4
- package/dist/plain/locale/getLocaleEraNames.js +56 -41
- package/dist/plain/locale/getLocaleMeridiems.d.ts +7 -4
- package/dist/plain/locale/getLocaleMeridiems.js +28 -22
- package/dist/plain/locale/getLocaleMonthNames.d.ts +14 -4
- package/dist/plain/locale/getLocaleMonthNames.js +34 -19
- package/dist/plain/locale/getLocaleWeekdayNames.d.ts +14 -7
- package/dist/plain/locale/getLocaleWeekdayNames.js +40 -22
- package/dist/plain/map/mapDatesInRange.d.ts +18 -1
- package/dist/plain/map/mapDatesInRange.js +53 -17
- package/dist/plain/parse/parseDateTimeWithPattern.d.ts +3 -2
- package/dist/plain/parse/parseDateTimeWithPattern.js +30 -24
- package/dist/plain/parse/parseDateWithPattern.d.ts +3 -2
- package/dist/plain/parse/parseDateWithPattern.js +22 -16
- package/dist/plain/parse/parseMicrosecondFromDateTime.d.ts +2 -1
- package/dist/plain/parse/parseMicrosecondFromDateTime.js +2 -1
- package/dist/plain/parse/parseMicrosecondFromTime.d.ts +2 -1
- package/dist/plain/parse/parseMicrosecondFromTime.js +2 -1
- package/dist/plain/parse/parseNanosecondFromDateTime.d.ts +2 -1
- package/dist/plain/parse/parseNanosecondFromDateTime.js +2 -1
- package/dist/plain/parse/parseNanosecondFromTime.d.ts +2 -1
- package/dist/plain/parse/parseNanosecondFromTime.js +2 -1
- package/dist/plain/parse/parseSql.d.ts +15 -12
- package/dist/plain/parse/parseSql.js +16 -13
- package/dist/plain/parse/parseTimeWithPattern.d.ts +3 -2
- package/dist/plain/parse/parseTimeWithPattern.js +27 -21
- package/dist/plain/parse/parseUnitFromDate.d.ts +9 -2
- package/dist/plain/parse/parseUnitFromDate.js +39 -19
- package/dist/plain/parse/parseUnitFromDateTime.d.ts +11 -3
- package/dist/plain/parse/parseUnitFromDateTime.js +54 -28
- package/dist/plain/parse/parseUnitFromTime.d.ts +9 -3
- package/dist/plain/parse/parseUnitFromTime.js +13 -3
- package/dist/plain/parse/parseWeekFromDate.d.ts +5 -0
- package/dist/plain/parse/parseWeekFromDate.js +24 -5
- package/dist/plain/parse/parseWeekFromDateTime.d.ts +5 -0
- package/dist/plain/parse/parseWeekFromDateTime.js +26 -5
- package/dist/plain/validate/isLeapSecond.d.ts +27 -9
- package/dist/plain/validate/isLeapSecond.js +30 -9
- package/dist/plain/validate/isLeapYear.d.ts +7 -1
- package/dist/plain/validate/isLeapYear.js +10 -1
- package/dist/plain/validate/isValidCalendarDate.d.ts +37 -6
- package/dist/plain/validate/isValidCalendarDate.js +37 -6
- package/dist/plain/validate/isValidDate.d.ts +9 -1
- package/dist/plain/validate/isValidDate.js +14 -5
- package/dist/plain/validate/isValidDateRange.d.ts +11 -4
- package/dist/plain/validate/isValidDateRange.js +32 -22
- package/dist/plain/validate/isValidDateTime.d.ts +7 -1
- package/dist/plain/validate/isValidDateTime.js +12 -5
- package/dist/plain/validate/isValidDateTimeRange.d.ts +3 -2
- package/dist/plain/validate/isValidDateTimeRange.js +30 -15
- package/dist/plain/validate/isValidIsoDateLike.d.ts +6 -1
- package/dist/plain/validate/isValidIsoDateLike.js +13 -8
- package/dist/plain/validate/isValidTime.d.ts +6 -1
- package/dist/plain/validate/isValidTime.js +10 -3
- package/dist/plain/validate/isValidTimeRange.d.ts +4 -2
- package/dist/plain/validate/isValidTimeRange.js +31 -27
- package/dist/precision/calculate/index.d.ts +1 -0
- package/dist/precision/calculate/index.js +1 -0
- package/dist/precision/calculate/truncateNanoseconds.d.ts +37 -0
- package/dist/precision/calculate/truncateNanoseconds.js +41 -0
- package/dist/precision/convert/fromDotNetTicks.d.ts +30 -0
- package/dist/precision/convert/fromDotNetTicks.js +39 -0
- package/dist/precision/convert/fromExcelSerial.d.ts +38 -0
- package/dist/precision/convert/fromExcelSerial.js +81 -0
- package/dist/precision/convert/fromFileTime.d.ts +30 -0
- package/dist/precision/convert/fromFileTime.js +39 -0
- package/dist/precision/convert/fromNanoseconds.d.ts +29 -0
- package/dist/precision/convert/fromNanoseconds.js +50 -0
- package/dist/precision/convert/fromNtpTimestamp.d.ts +43 -0
- package/dist/precision/convert/fromNtpTimestamp.js +57 -0
- package/dist/precision/convert/fromPgMicroseconds.d.ts +26 -0
- package/dist/precision/convert/fromPgMicroseconds.js +33 -0
- package/dist/precision/convert/index.d.ts +12 -0
- package/dist/precision/convert/index.js +12 -0
- package/dist/precision/convert/toDotNetTicks.d.ts +29 -0
- package/dist/precision/convert/toDotNetTicks.js +40 -0
- package/dist/precision/convert/toExcelSerial.d.ts +56 -0
- package/dist/precision/convert/toExcelSerial.js +85 -0
- package/dist/precision/convert/toFileTime.d.ts +31 -0
- package/dist/precision/convert/toFileTime.js +43 -0
- package/dist/precision/convert/toNanoseconds.d.ts +37 -0
- package/dist/precision/convert/toNanoseconds.js +40 -0
- package/dist/precision/convert/toNtpTimestamp.d.ts +30 -0
- package/dist/precision/convert/toNtpTimestamp.js +38 -0
- package/dist/precision/convert/toPgMicroseconds.d.ts +29 -0
- package/dist/precision/convert/toPgMicroseconds.js +42 -0
- package/dist/precision/format/formatNanoseconds.d.ts +26 -0
- package/dist/precision/format/formatNanoseconds.js +32 -0
- package/dist/precision/format/index.d.ts +1 -0
- package/dist/precision/format/index.js +1 -0
- package/dist/precision/index.d.ts +6 -0
- package/dist/precision/index.js +7 -0
- package/dist/precision/parse/index.d.ts +1 -0
- package/dist/precision/parse/index.js +1 -0
- package/dist/precision/parse/parseNanoseconds.d.ts +27 -0
- package/dist/precision/parse/parseNanoseconds.js +32 -0
- package/dist/precision/validate/index.d.ts +3 -0
- package/dist/precision/validate/index.js +3 -0
- package/dist/precision/validate/isValidInstant.d.ts +37 -0
- package/dist/precision/validate/isValidInstant.js +40 -0
- package/dist/precision/validate/isValidNanoPattern.d.ts +27 -0
- package/dist/precision/validate/isValidNanoPattern.js +40 -0
- package/dist/precision/validate/isValidNanoseconds.d.ts +25 -0
- package/dist/precision/validate/isValidNanoseconds.js +28 -0
- package/dist/regex/calendar-date.d.ts +25 -14
- package/dist/regex/calendar-date.js +26 -15
- package/dist/regex/calendar-zoned-date-time.d.ts +22 -38
- package/dist/regex/calendar-zoned-date-time.js +23 -39
- package/dist/regex/date-time.d.ts +14 -4
- package/dist/regex/date-time.js +15 -5
- package/dist/regex/date.d.ts +45 -3
- package/dist/regex/date.js +47 -5
- package/dist/regex/http-date.d.ts +10 -6
- package/dist/regex/http-date.js +10 -6
- package/dist/regex/index.d.ts +3 -0
- package/dist/regex/index.js +4 -0
- package/dist/regex/leap-second.d.ts +41 -8
- package/dist/regex/leap-second.js +42 -9
- package/dist/regex/nanoseconds.d.ts +20 -0
- package/dist/regex/nanoseconds.js +20 -0
- package/dist/regex/rfc-2822.d.ts +15 -7
- package/dist/regex/rfc-2822.js +15 -7
- package/dist/regex/rfc-3339.d.ts +8 -1
- package/dist/regex/rfc-3339.js +9 -2
- package/dist/regex/sql-date-time.d.ts +27 -8
- package/dist/regex/sql-date-time.js +28 -9
- package/dist/regex/time-zone-like.d.ts +24 -15
- package/dist/regex/time-zone-like.js +25 -16
- package/dist/regex/time.d.ts +20 -6
- package/dist/regex/time.js +20 -6
- package/dist/regex/unix.d.ts +13 -5
- package/dist/regex/unix.js +13 -5
- package/dist/regex/utc-date-time.d.ts +19 -9
- package/dist/regex/utc-date-time.js +20 -10
- package/dist/regex/utc-offset.d.ts +24 -0
- package/dist/regex/utc-offset.js +24 -0
- package/dist/span/calculate/index.d.ts +3 -0
- package/dist/span/calculate/index.js +3 -0
- package/dist/span/calculate/spanMs.d.ts +52 -0
- package/dist/span/calculate/spanMs.js +80 -0
- package/dist/span/calculate/spanNs.d.ts +43 -0
- package/dist/span/calculate/spanNs.js +51 -0
- package/dist/span/calculate/spanWallClock.d.ts +60 -0
- package/dist/span/calculate/spanWallClock.js +80 -0
- package/dist/span/index.d.ts +3 -0
- package/dist/span/index.js +4 -0
- package/dist/span/validate/index.d.ts +1 -0
- package/dist/span/validate/index.js +1 -0
- package/dist/span/validate/isValidSpan.d.ts +37 -0
- package/dist/span/validate/isValidSpan.js +41 -0
- package/dist/transport/calculate/dwellTime.d.ts +72 -0
- package/dist/transport/calculate/dwellTime.js +126 -0
- package/dist/transport/calculate/index.d.ts +2 -0
- package/dist/transport/calculate/index.js +2 -0
- package/dist/transport/calculate/transitTime.d.ts +53 -0
- package/dist/transport/calculate/transitTime.js +118 -0
- package/dist/transport/convert/etaAtZone.d.ts +36 -0
- package/dist/transport/convert/etaAtZone.js +53 -0
- package/dist/transport/convert/index.d.ts +1 -0
- package/dist/transport/convert/index.js +1 -0
- package/dist/transport/index.d.ts +3 -0
- package/dist/transport/index.js +4 -0
- package/dist/types/business-calendar.d.ts +27 -0
- package/dist/types/business-calendar.js +0 -0
- package/dist/types/calendar-system.d.ts +9 -1
- package/dist/types/fiscal-calendar.d.ts +22 -0
- package/dist/types/fiscal-calendar.js +0 -0
- package/dist/types/free-time-options.d.ts +34 -0
- package/dist/types/free-time-options.js +0 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +6 -0
- package/dist/types/interval.d.ts +18 -0
- package/dist/types/interval.js +0 -0
- package/dist/types/now-unit.d.ts +1 -1
- package/dist/types/roll-convention.d.ts +32 -0
- package/dist/types/roll-convention.js +0 -0
- package/dist/types/utc-now-unit.d.ts +1 -1
- package/dist/types/zone-bucket-unit.d.ts +11 -0
- package/dist/types/zone-bucket-unit.js +0 -0
- package/dist/unix/calculate/addUnix.d.ts +10 -4
- package/dist/unix/calculate/addUnix.js +39 -26
- package/dist/unix/calculate/diffUnix.d.ts +38 -11
- package/dist/unix/calculate/diffUnix.js +84 -40
- package/dist/unix/calculate/diffUnixAsDuration.d.ts +17 -7
- package/dist/unix/calculate/diffUnixAsDuration.js +42 -23
- package/dist/unix/calculate/endOfQuarterForUnix.d.ts +15 -11
- package/dist/unix/calculate/endOfQuarterForUnix.js +20 -39
- package/dist/unix/calculate/endOfUnix.d.ts +23 -18
- package/dist/unix/calculate/endOfUnix.js +37 -15
- package/dist/unix/calculate/isBetweenUnix.d.ts +12 -6
- package/dist/unix/calculate/isBetweenUnix.js +34 -23
- package/dist/unix/calculate/maxUnix.d.ts +6 -3
- package/dist/unix/calculate/maxUnix.js +17 -8
- package/dist/unix/calculate/minUnix.d.ts +6 -3
- package/dist/unix/calculate/minUnix.js +17 -8
- package/dist/unix/calculate/roundUnix.d.ts +24 -10
- package/dist/unix/calculate/roundUnix.js +67 -42
- package/dist/unix/calculate/setUnix.d.ts +14 -5
- package/dist/unix/calculate/setUnix.js +48 -29
- package/dist/unix/calculate/sortUnix.d.ts +6 -3
- package/dist/unix/calculate/sortUnix.js +19 -11
- package/dist/unix/calculate/startOfQuarterForUnix.d.ts +17 -12
- package/dist/unix/calculate/startOfQuarterForUnix.js +22 -30
- package/dist/unix/calculate/startOfUnix.d.ts +23 -18
- package/dist/unix/calculate/startOfUnix.js +37 -15
- package/dist/unix/calculate/subtractUnix.d.ts +10 -4
- package/dist/unix/calculate/subtractUnix.js +39 -26
- package/dist/unix/compare/areUnixEqual.d.ts +9 -5
- package/dist/unix/compare/areUnixEqual.js +17 -13
- package/dist/unix/compare/areUnixEqualBy.d.ts +14 -7
- package/dist/unix/compare/areUnixEqualBy.js +14 -7
- package/dist/unix/compare/isAfterUnix.d.ts +8 -4
- package/dist/unix/compare/isAfterUnix.js +16 -12
- package/dist/unix/compare/isBeforeUnix.d.ts +7 -4
- package/dist/unix/compare/isBeforeUnix.js +15 -12
- package/dist/unix/convert/convertUnixToPlainDate.d.ts +17 -9
- package/dist/unix/convert/convertUnixToPlainDate.js +34 -21
- package/dist/unix/convert/convertUnixToPlainDateTime.d.ts +15 -9
- package/dist/unix/convert/convertUnixToPlainDateTime.js +32 -21
- package/dist/unix/convert/convertUnixToPlainTime.d.ts +15 -9
- package/dist/unix/convert/convertUnixToPlainTime.js +32 -21
- package/dist/unix/convert/convertUnixToUtc.d.ts +15 -7
- package/dist/unix/convert/convertUnixToUtc.js +20 -15
- package/dist/unix/convert/convertUnixToZoned.d.ts +17 -10
- package/dist/unix/convert/convertUnixToZoned.js +31 -20
- package/dist/unix/format/formatCalendarUnix.d.ts +22 -19
- package/dist/unix/format/formatCalendarUnix.js +35 -81
- package/dist/unix/format/formatRelativeUnix.d.ts +25 -8
- package/dist/unix/format/formatRelativeUnix.js +46 -93
- package/dist/unix/format/formatUnix.d.ts +26 -4
- package/dist/unix/format/formatUnix.js +48 -34
- package/dist/unix/get/getUnixNow.d.ts +13 -7
- package/dist/unix/get/getUnixNow.js +27 -17
- package/dist/unix/get/getUnixNowUnit.d.ts +5 -2
- package/dist/unix/get/getUnixNowUnit.js +9 -35
- package/dist/unix/index.d.ts +1 -0
- package/dist/unix/index.js +2 -0
- package/dist/unix/interval/intervalAbutsUnix.d.ts +17 -12
- package/dist/unix/interval/intervalAbutsUnix.js +23 -41
- package/dist/unix/interval/intervalContainsUnix.d.ts +17 -7
- package/dist/unix/interval/intervalContainsUnix.js +25 -37
- package/dist/unix/interval/intervalCountUnix.d.ts +30 -13
- package/dist/unix/interval/intervalCountUnix.js +49 -23
- package/dist/unix/interval/intervalDifferenceUnix.d.ts +19 -10
- package/dist/unix/interval/intervalDifferenceUnix.js +25 -43
- package/dist/unix/interval/intervalDivideEquallyUnix.d.ts +24 -10
- package/dist/unix/interval/intervalDivideEquallyUnix.js +57 -36
- package/dist/unix/interval/intervalEngulfsUnix.d.ts +13 -7
- package/dist/unix/interval/intervalEngulfsUnix.js +18 -30
- package/dist/unix/interval/intervalFromDurationUnix.d.ts +10 -6
- package/dist/unix/interval/intervalFromDurationUnix.js +51 -39
- package/dist/unix/interval/intervalIntersectionUnix.d.ts +18 -11
- package/dist/unix/interval/intervalIntersectionUnix.js +25 -46
- package/dist/unix/interval/intervalLengthUnix.d.ts +21 -9
- package/dist/unix/interval/intervalLengthUnix.js +41 -18
- package/dist/unix/interval/intervalOverlappingDaysUnix.d.ts +26 -12
- package/dist/unix/interval/intervalOverlappingDaysUnix.js +67 -63
- package/dist/unix/interval/intervalSplitAtUnix.d.ts +11 -6
- package/dist/unix/interval/intervalSplitAtUnix.js +41 -34
- package/dist/unix/interval/intervalUnionUnix.d.ts +15 -9
- package/dist/unix/interval/intervalUnionUnix.js +20 -42
- package/dist/unix/interval/intervalXorAllUnix.d.ts +8 -6
- package/dist/unix/interval/intervalXorAllUnix.js +21 -56
- package/dist/unix/interval/intervalXorUnix.d.ts +22 -11
- package/dist/unix/interval/intervalXorUnix.js +28 -56
- package/dist/unix/interval/intervalsOverlapUnix.d.ts +16 -10
- package/dist/unix/interval/intervalsOverlapUnix.js +21 -37
- package/dist/unix/interval/mergeIntervalsUnix.d.ts +10 -4
- package/dist/unix/interval/mergeIntervalsUnix.js +25 -36
- package/dist/unix/interval/splitIntervalByUnitUnix.d.ts +38 -8
- package/dist/unix/interval/splitIntervalByUnitUnix.js +72 -56
- package/dist/unix/interval/validate/isValidUnixInterval.d.ts +12 -6
- package/dist/unix/interval/validate/isValidUnixInterval.js +17 -16
- package/dist/unix/parse/index.d.ts +2 -0
- package/dist/unix/parse/index.js +2 -0
- package/dist/unix/parse/parseDateFromUnix.d.ts +10 -8
- package/dist/unix/parse/parseDateFromUnix.js +17 -29
- package/dist/unix/parse/parseDayFromUnix.d.ts +6 -4
- package/dist/unix/parse/parseDayFromUnix.js +18 -5
- package/dist/unix/parse/parseDayOfWeekFromUnix.d.ts +8 -5
- package/dist/unix/parse/parseDayOfWeekFromUnix.js +15 -28
- package/dist/unix/parse/parseHourFromUnix.d.ts +6 -4
- package/dist/unix/parse/parseHourFromUnix.js +18 -5
- package/dist/unix/parse/parseMicrosecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMicrosecondFromUnix.js +16 -3
- package/dist/unix/parse/parseMillisecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMillisecondFromUnix.js +16 -3
- package/dist/unix/parse/parseMinuteFromUnix.d.ts +6 -4
- package/dist/unix/parse/parseMinuteFromUnix.js +18 -5
- package/dist/unix/parse/parseMonthFromUnix.d.ts +6 -4
- package/dist/unix/parse/parseMonthFromUnix.js +18 -5
- package/dist/unix/parse/parseNanosecondFromUnix.d.ts +8 -5
- package/dist/unix/parse/parseNanosecondFromUnix.js +20 -6
- package/dist/unix/parse/parseSecondFromUnix.d.ts +5 -3
- package/dist/unix/parse/parseSecondFromUnix.js +17 -4
- package/dist/unix/parse/parseTimeFromUnix.d.ts +10 -8
- package/dist/unix/parse/parseTimeFromUnix.js +17 -29
- package/dist/unix/parse/parseUnitFromUnix.d.ts +18 -11
- package/dist/unix/parse/parseUnitFromUnix.js +57 -55
- package/dist/unix/parse/parseWeekFromUnix.d.ts +15 -7
- package/dist/unix/parse/parseWeekFromUnix.js +32 -30
- package/dist/unix/parse/parseYearFromUnix.d.ts +5 -3
- package/dist/unix/parse/parseYearFromUnix.js +17 -4
- package/dist/unix/validate/isValidUnixMilliseconds.d.ts +8 -5
- package/dist/unix/validate/isValidUnixMilliseconds.js +10 -9
- package/dist/unix/validate/isValidUnixRange.d.ts +13 -7
- package/dist/unix/validate/isValidUnixRange.js +29 -19
- package/dist/unix/validate/isValidUnixSeconds.d.ts +8 -5
- package/dist/unix/validate/isValidUnixSeconds.js +10 -9
- package/dist/unix/validate/isValidUnixUnit.d.ts +9 -7
- package/dist/unix/validate/isValidUnixUnit.js +6 -8
- package/dist/utc/calculate/addUtc.js +26 -12
- package/dist/utc/calculate/diffUtc.d.ts +22 -7
- package/dist/utc/calculate/diffUtc.js +75 -31
- package/dist/utc/calculate/diffUtcAsDuration.d.ts +2 -2
- package/dist/utc/calculate/diffUtcAsDuration.js +10 -3
- package/dist/utc/calculate/endOfQuarterForUtc.d.ts +1 -1
- package/dist/utc/calculate/endOfQuarterForUtc.js +1 -1
- package/dist/utc/calculate/endOfUtc.d.ts +11 -4
- package/dist/utc/calculate/endOfUtc.js +22 -5
- package/dist/utc/calculate/isBetweenUtc.js +40 -24
- package/dist/utc/calculate/maxUtc.js +19 -12
- package/dist/utc/calculate/minUtc.js +19 -12
- package/dist/utc/calculate/roundUtc.d.ts +16 -2
- package/dist/utc/calculate/roundUtc.js +42 -31
- package/dist/utc/calculate/setUtc.d.ts +4 -8
- package/dist/utc/calculate/setUtc.js +25 -18
- package/dist/utc/calculate/sortUtc.js +17 -10
- package/dist/utc/calculate/startOfQuarterForUtc.d.ts +2 -0
- package/dist/utc/calculate/startOfQuarterForUtc.js +12 -1
- package/dist/utc/calculate/startOfUtc.d.ts +6 -4
- package/dist/utc/calculate/startOfUtc.js +17 -5
- package/dist/utc/calculate/subtractUtc.js +26 -12
- package/dist/utc/chop/chopUtc.d.ts +5 -2
- package/dist/utc/chop/chopUtc.js +8 -4
- package/dist/utc/compare/areUtcEqualBy.d.ts +10 -5
- package/dist/utc/compare/areUtcEqualBy.js +34 -11
- package/dist/utc/convert/convertUtcToPlainDate.js +22 -10
- package/dist/utc/convert/convertUtcToPlainDateTime.js +28 -16
- package/dist/utc/convert/convertUtcToPlainTime.js +22 -10
- package/dist/utc/convert/convertUtcToUnix.d.ts +12 -5
- package/dist/utc/convert/convertUtcToUnix.js +22 -13
- package/dist/utc/format/formatCalendarUtc.d.ts +11 -6
- package/dist/utc/format/formatCalendarUtc.js +32 -41
- package/dist/utc/format/formatHttp.d.ts +9 -3
- package/dist/utc/format/formatHttp.js +14 -12
- package/dist/utc/format/formatRelativeUtc.d.ts +18 -6
- package/dist/utc/format/formatRelativeUtc.js +43 -51
- package/dist/utc/format/formatUtc.d.ts +20 -3
- package/dist/utc/format/formatUtc.js +41 -12
- package/dist/utc/get/getUtcNowUnit.d.ts +3 -0
- package/dist/utc/get/getUtcNowUnit.js +11 -33
- package/dist/utc/index.d.ts +1 -0
- package/dist/utc/index.js +2 -0
- package/dist/utc/interval/intervalAbutsUtc.d.ts +10 -7
- package/dist/utc/interval/intervalAbutsUtc.js +18 -30
- package/dist/utc/interval/intervalContainsUtc.d.ts +19 -11
- package/dist/utc/interval/intervalContainsUtc.js +33 -34
- package/dist/utc/interval/intervalCountUtc.d.ts +3 -4
- package/dist/utc/interval/intervalCountUtc.js +12 -18
- package/dist/utc/interval/intervalDifferenceUtc.d.ts +13 -5
- package/dist/utc/interval/intervalDifferenceUtc.js +25 -51
- package/dist/utc/interval/intervalDivideEquallyUtc.d.ts +16 -3
- package/dist/utc/interval/intervalDivideEquallyUtc.js +54 -34
- package/dist/utc/interval/intervalEngulfsUtc.d.ts +17 -12
- package/dist/utc/interval/intervalEngulfsUtc.js +25 -26
- package/dist/utc/interval/intervalFromDurationUtc.js +5 -0
- package/dist/utc/interval/intervalIntersectionUtc.d.ts +12 -6
- package/dist/utc/interval/intervalIntersectionUtc.js +24 -41
- package/dist/utc/interval/intervalLengthUtc.js +5 -7
- package/dist/utc/interval/intervalOverlappingDaysUtc.d.ts +7 -13
- package/dist/utc/interval/intervalOverlappingDaysUtc.js +25 -36
- package/dist/utc/interval/intervalSplitAtUtc.d.ts +7 -2
- package/dist/utc/interval/intervalSplitAtUtc.js +39 -33
- package/dist/utc/interval/intervalUnionUtc.d.ts +15 -7
- package/dist/utc/interval/intervalUnionUtc.js +31 -42
- package/dist/utc/interval/intervalXorAllUtc.d.ts +7 -4
- package/dist/utc/interval/intervalXorAllUtc.js +30 -52
- package/dist/utc/interval/intervalXorUtc.d.ts +8 -6
- package/dist/utc/interval/intervalXorUtc.js +22 -56
- package/dist/utc/interval/intervalsOverlapUtc.d.ts +15 -9
- package/dist/utc/interval/intervalsOverlapUtc.js +23 -39
- package/dist/utc/interval/mergeIntervalsUtc.d.ts +9 -2
- package/dist/utc/interval/mergeIntervalsUtc.js +23 -36
- package/dist/utc/interval/splitIntervalByUnitUtc.d.ts +23 -2
- package/dist/utc/interval/splitIntervalByUnitUtc.js +65 -44
- package/dist/utc/interval/validate/isValidUtcInterval.d.ts +5 -0
- package/dist/utc/interval/validate/isValidUtcInterval.js +7 -6
- package/dist/utc/parse/parseDateFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseDateFromUtc.js +14 -9
- package/dist/utc/parse/parseDayFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseDayFromUtc.js +14 -8
- package/dist/utc/parse/parseDayOfWeekFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseDayOfWeekFromUtc.js +24 -6
- package/dist/utc/parse/parseHourFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseHourFromUtc.js +14 -8
- package/dist/utc/parse/parseHttp.d.ts +39 -14
- package/dist/utc/parse/parseHttp.js +69 -28
- package/dist/utc/parse/parseMicrosecondFromUtc.d.ts +9 -2
- package/dist/utc/parse/parseMicrosecondFromUtc.js +18 -9
- package/dist/utc/parse/parseMillisecondFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseMillisecondFromUtc.js +16 -8
- package/dist/utc/parse/parseMinuteFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseMinuteFromUtc.js +14 -8
- package/dist/utc/parse/parseMonthFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseMonthFromUtc.js +14 -8
- package/dist/utc/parse/parseNanosecondFromUtc.d.ts +9 -2
- package/dist/utc/parse/parseNanosecondFromUtc.js +18 -9
- package/dist/utc/parse/parseSecondFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseSecondFromUtc.js +14 -8
- package/dist/utc/parse/parseTimeFromUtc.js +21 -10
- package/dist/utc/parse/parseUnitFromUtc.d.ts +18 -7
- package/dist/utc/parse/parseUnitFromUtc.js +58 -31
- package/dist/utc/parse/parseWeekFromUtc.d.ts +16 -3
- package/dist/utc/parse/parseWeekFromUtc.js +38 -10
- package/dist/utc/parse/parseYearFromUtc.d.ts +7 -1
- package/dist/utc/parse/parseYearFromUtc.js +14 -8
- package/dist/utc/validate/isValidUtc.d.ts +8 -1
- package/dist/utc/validate/isValidUtc.js +12 -3
- package/dist/utc/validate/isValidUtcRange.d.ts +3 -2
- package/dist/utc/validate/isValidUtcRange.js +30 -19
- package/dist/zoned/calculate/addZoned.d.ts +40 -27
- package/dist/zoned/calculate/addZoned.js +71 -56
- package/dist/zoned/calculate/addZonedBusinessDays.d.ts +2 -0
- package/dist/zoned/calculate/addZonedBusinessDays.js +5 -2
- package/dist/zoned/calculate/clampZoned.js +4 -3
- package/dist/zoned/calculate/closestZonedTo.d.ts +6 -6
- package/dist/zoned/calculate/closestZonedTo.js +35 -26
- package/dist/zoned/calculate/cycleZoned.d.ts +10 -7
- package/dist/zoned/calculate/cycleZoned.js +19 -11
- package/dist/zoned/calculate/diffZoned.d.ts +39 -17
- package/dist/zoned/calculate/diffZoned.js +90 -45
- package/dist/zoned/calculate/diffZonedAsDuration.d.ts +19 -9
- package/dist/zoned/calculate/diffZonedAsDuration.js +32 -15
- package/dist/zoned/calculate/endOfQuarterForZoned.d.ts +11 -11
- package/dist/zoned/calculate/endOfQuarterForZoned.js +32 -31
- package/dist/zoned/calculate/endOfZoned.d.ts +21 -14
- package/dist/zoned/calculate/endOfZoned.js +25 -111
- package/dist/zoned/calculate/getHoursInZonedDay.d.ts +8 -1
- package/dist/zoned/calculate/getHoursInZonedDay.js +10 -14
- package/dist/zoned/calculate/getLocaleZonedDayOfWeek.d.ts +8 -4
- package/dist/zoned/calculate/getLocaleZonedDayOfWeek.js +9 -6
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.d.ts +20 -26
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.js +40 -44
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.d.ts +16 -24
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.js +36 -42
- package/dist/zoned/calculate/getQuarterForZoned.js +2 -2
- package/dist/zoned/calculate/maxZoned.js +20 -12
- package/dist/zoned/calculate/minZoned.d.ts +1 -1
- package/dist/zoned/calculate/minZoned.js +21 -13
- package/dist/zoned/calculate/roundZoned.d.ts +18 -4
- package/dist/zoned/calculate/roundZoned.js +58 -33
- package/dist/zoned/calculate/setZoned.d.ts +9 -3
- package/dist/zoned/calculate/setZoned.js +39 -18
- package/dist/zoned/calculate/sortZoned.js +18 -10
- package/dist/zoned/calculate/startOfQuarterForZoned.d.ts +4 -7
- package/dist/zoned/calculate/startOfQuarterForZoned.js +23 -17
- package/dist/zoned/calculate/startOfZoned.d.ts +17 -13
- package/dist/zoned/calculate/startOfZoned.js +21 -103
- package/dist/zoned/calculate/subtractZoned.d.ts +36 -24
- package/dist/zoned/calculate/subtractZoned.js +66 -50
- package/dist/zoned/calculate/subtractZonedBusinessDays.d.ts +2 -0
- package/dist/zoned/calculate/subtractZonedBusinessDays.js +5 -2
- package/dist/zoned/chop/chopZonedDate.js +2 -2
- package/dist/zoned/chop/chopZonedDateTime.js +2 -2
- package/dist/zoned/chop/chopZonedMilliseconds.js +2 -2
- package/dist/zoned/chop/chopZonedSeconds.js +2 -2
- package/dist/zoned/chop/chopZonedTime.js +2 -2
- package/dist/zoned/chop/chopZonedTimezone.js +2 -2
- package/dist/zoned/compare/areZonedEqual.js +3 -2
- package/dist/zoned/compare/areZonedEqualBy.d.ts +15 -2
- package/dist/zoned/compare/areZonedEqualBy.js +45 -12
- package/dist/zoned/compare/isAfterZoned.js +3 -2
- package/dist/zoned/compare/isBeforeZoned.d.ts +1 -1
- package/dist/zoned/compare/isBeforeZoned.js +4 -3
- package/dist/zoned/compare/isBetweenZoned.js +46 -29
- package/dist/zoned/compare/isInDaylightSaving.js +4 -4
- package/dist/zoned/compare/isZonedBusinessDay.d.ts +7 -4
- package/dist/zoned/compare/isZonedBusinessDay.js +9 -6
- package/dist/zoned/compare/isZonedFuture.js +2 -1
- package/dist/zoned/compare/isZonedPast.js +2 -1
- package/dist/zoned/compare/isZonedRelativeDay.js +2 -1
- package/dist/zoned/compare/isZonedThisUnit.d.ts +12 -4
- package/dist/zoned/compare/isZonedThisUnit.js +37 -16
- package/dist/zoned/compare/isZonedWeekend.d.ts +8 -4
- package/dist/zoned/compare/isZonedWeekend.js +9 -6
- package/dist/zoned/convert/convertPlainDateTimeToZoned.d.ts +10 -5
- package/dist/zoned/convert/convertPlainDateTimeToZoned.js +34 -16
- package/dist/zoned/convert/convertZonedToCalendar.d.ts +26 -38
- package/dist/zoned/convert/convertZonedToCalendar.js +33 -48
- package/dist/zoned/convert/convertZonedToPlainDateTime.d.ts +6 -0
- package/dist/zoned/convert/convertZonedToPlainDateTime.js +8 -2
- package/dist/zoned/convert/convertZonedToUnix.d.ts +12 -6
- package/dist/zoned/convert/convertZonedToUnix.js +23 -16
- package/dist/zoned/convert/convertZonedToUtc.js +2 -2
- package/dist/zoned/convert/convertZonedToZoned.js +2 -2
- package/dist/zoned/format/formatCalendarZoned.d.ts +7 -3
- package/dist/zoned/format/formatCalendarZoned.js +37 -39
- package/dist/zoned/format/formatRelativeZoned.d.ts +15 -6
- package/dist/zoned/format/formatRelativeZoned.js +54 -54
- package/dist/zoned/format/formatRfc2822.d.ts +14 -1
- package/dist/zoned/format/formatRfc2822.js +27 -13
- package/dist/zoned/format/formatRfc3339.d.ts +14 -1
- package/dist/zoned/format/formatRfc3339.js +29 -3
- package/dist/zoned/format/formatTimeZoneName.d.ts +3 -2
- package/dist/zoned/format/formatTimeZoneName.js +28 -18
- package/dist/zoned/format/formatZonedDateTime.d.ts +25 -5
- package/dist/zoned/format/formatZonedDateTime.js +40 -9
- package/dist/zoned/format/formatZonedRange.d.ts +24 -6
- package/dist/zoned/format/formatZonedRange.js +61 -28
- package/dist/zoned/format/formatZonedToParts.d.ts +29 -6
- package/dist/zoned/format/formatZonedToParts.js +42 -13
- package/dist/zoned/get/getDstTransitions.d.ts +6 -1
- package/dist/zoned/get/getDstTransitions.js +17 -15
- package/dist/zoned/get/getTimeZoneOffset.d.ts +11 -1
- package/dist/zoned/get/getTimeZoneOffset.js +19 -2
- package/dist/zoned/get/getZonedNow.js +20 -9
- package/dist/zoned/get/getZonedNowUnit.d.ts +8 -4
- package/dist/zoned/get/getZonedNowUnit.js +15 -31
- package/dist/zoned/index.js +1 -1
- package/dist/zoned/interval/intervalAbutsZoned.d.ts +18 -11
- package/dist/zoned/interval/intervalAbutsZoned.js +24 -25
- package/dist/zoned/interval/intervalContainsZoned.d.ts +16 -7
- package/dist/zoned/interval/intervalContainsZoned.js +22 -14
- package/dist/zoned/interval/intervalCountZoned.d.ts +19 -11
- package/dist/zoned/interval/intervalCountZoned.js +32 -27
- package/dist/zoned/interval/intervalDifferenceZoned.d.ts +13 -7
- package/dist/zoned/interval/intervalDifferenceZoned.js +24 -36
- package/dist/zoned/interval/intervalDivideEquallyZoned.d.ts +18 -9
- package/dist/zoned/interval/intervalDivideEquallyZoned.js +67 -46
- package/dist/zoned/interval/intervalEngulfsZoned.d.ts +10 -5
- package/dist/zoned/interval/intervalEngulfsZoned.js +16 -10
- package/dist/zoned/interval/intervalFromDurationZoned.d.ts +25 -11
- package/dist/zoned/interval/intervalFromDurationZoned.js +61 -44
- package/dist/zoned/interval/intervalIntersectionZoned.d.ts +12 -6
- package/dist/zoned/interval/intervalIntersectionZoned.js +24 -18
- package/dist/zoned/interval/intervalLengthZoned.d.ts +15 -6
- package/dist/zoned/interval/intervalLengthZoned.js +23 -9
- package/dist/zoned/interval/intervalOverlappingDaysZoned.d.ts +28 -17
- package/dist/zoned/interval/intervalOverlappingDaysZoned.js +46 -34
- package/dist/zoned/interval/intervalSplitAtZoned.d.ts +6 -3
- package/dist/zoned/interval/intervalSplitAtZoned.js +52 -42
- package/dist/zoned/interval/intervalUnionZoned.d.ts +14 -8
- package/dist/zoned/interval/intervalUnionZoned.js +25 -20
- package/dist/zoned/interval/intervalXorAllZoned.d.ts +9 -7
- package/dist/zoned/interval/intervalXorAllZoned.js +42 -73
- package/dist/zoned/interval/intervalXorZoned.d.ts +20 -12
- package/dist/zoned/interval/intervalXorZoned.js +34 -64
- package/dist/zoned/interval/intervalsOverlapZoned.d.ts +15 -7
- package/dist/zoned/interval/intervalsOverlapZoned.js +21 -12
- package/dist/zoned/interval/mergeIntervalsZoned.d.ts +10 -3
- package/dist/zoned/interval/mergeIntervalsZoned.js +44 -41
- package/dist/zoned/interval/splitIntervalByUnitZoned.d.ts +28 -5
- package/dist/zoned/interval/splitIntervalByUnitZoned.js +72 -39
- package/dist/zoned/interval/validate/isValidCalendarZonedInterval.d.ts +13 -10
- package/dist/zoned/interval/validate/isValidCalendarZonedInterval.js +13 -10
- package/dist/zoned/interval/validate/isValidZonedInterval.d.ts +7 -5
- package/dist/zoned/interval/validate/isValidZonedInterval.js +12 -16
- package/dist/zoned/map/mapZonedDatesInRange.d.ts +17 -1
- package/dist/zoned/map/mapZonedDatesInRange.js +62 -26
- package/dist/zoned/map/mapZonedHoursInDay.d.ts +10 -13
- package/dist/zoned/map/mapZonedHoursInDay.js +13 -21
- package/dist/zoned/parse/getZonedOffset.js +2 -2
- package/dist/zoned/parse/getZonedOffsetAs.d.ts +4 -2
- package/dist/zoned/parse/getZonedOffsetAs.js +10 -5
- package/dist/zoned/parse/parseDateFromZoned.js +2 -2
- package/dist/zoned/parse/parseDateTimeFromZoned.js +2 -2
- package/dist/zoned/parse/parseDayFromZoned.js +2 -2
- package/dist/zoned/parse/parseDayOfWeekFromZoned.js +2 -2
- package/dist/zoned/parse/parseHourFromZoned.js +2 -2
- package/dist/zoned/parse/parseMicrosecondFromZoned.d.ts +2 -1
- package/dist/zoned/parse/parseMicrosecondFromZoned.js +4 -3
- package/dist/zoned/parse/parseMillisecondFromZoned.js +2 -2
- package/dist/zoned/parse/parseMinuteFromZoned.js +2 -2
- package/dist/zoned/parse/parseMonthFromZoned.js +2 -2
- package/dist/zoned/parse/parseNanosecondFromZoned.d.ts +2 -1
- package/dist/zoned/parse/parseNanosecondFromZoned.js +4 -3
- package/dist/zoned/parse/parseRfc2822.d.ts +32 -12
- package/dist/zoned/parse/parseRfc2822.js +47 -45
- package/dist/zoned/parse/parseRfc3339.d.ts +6 -0
- package/dist/zoned/parse/parseRfc3339.js +6 -0
- package/dist/zoned/parse/parseSecondFromZoned.js +2 -2
- package/dist/zoned/parse/parseTimeFromZoned.js +2 -2
- package/dist/zoned/parse/parseTimeZoneFromZoned.js +2 -2
- package/dist/zoned/parse/parseUnitFromZoned.d.ts +14 -5
- package/dist/zoned/parse/parseUnitFromZoned.js +59 -33
- package/dist/zoned/parse/parseWeekFromZoned.d.ts +13 -3
- package/dist/zoned/parse/parseWeekFromZoned.js +34 -10
- package/dist/zoned/parse/parseYearFromZoned.js +2 -2
- package/dist/zoned/validate/hasDaylightSaving.js +3 -3
- package/dist/zoned/validate/isValidCalendarZonedDateTime.d.ts +31 -16
- package/dist/zoned/validate/isValidCalendarZonedDateTime.js +31 -16
- package/dist/zoned/validate/isValidTimeZone.d.ts +15 -2
- package/dist/zoned/validate/isValidTimeZone.js +17 -4
- package/dist/zoned/validate/isValidZonedDateTime.d.ts +14 -7
- package/dist/zoned/validate/isValidZonedDateTime.js +20 -12
- package/dist/zoned/validate/isValidZonedRange.d.ts +9 -2
- package/dist/zoned/validate/isValidZonedRange.js +44 -16
- package/package.json +510 -34
- package/skills/gmt-arithmetic/SKILL.md +197 -16
- package/skills/gmt-basics/SKILL.md +61 -14
- package/skills/gmt-integration/SKILL.md +54 -8
- package/skills/gmt-timezone/SKILL.md +208 -24
- package/dist/internal/advanceBusinessDays.d.ts +0 -2
- package/dist/internal/advanceBusinessDays.js +0 -15
- package/dist/internal/ethiopicFamilyCalendar.d.ts +0 -47
- package/dist/internal/ethiopicFamilyCalendar.js +0 -136
- package/dist/internal/getLocaleMinimalDaysInFirstWeek.d.ts +0 -20
- package/dist/internal/getLocaleMinimalDaysInFirstWeek.js +0 -31
- package/dist/internal/resolveUnixTimeZone.d.ts +0 -20
- package/dist/internal/resolveUnixTimeZone.js +0 -30
- package/dist/unix/calculate/startOrEndOfUnix.d.ts +0 -27
- package/dist/unix/calculate/startOrEndOfUnix.js +0 -140
- package/dist/unix/interval/resolveUnixIntervalPair.d.ts +0 -7
- package/dist/unix/interval/resolveUnixIntervalPair.js +0 -36
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { spanNs } from "./spanNs.js";
|
|
2
|
+
/** Nanoseconds in a millisecond. */
|
|
3
|
+
const NANOSECONDS_PER_MILLISECOND = 1000000n;
|
|
4
|
+
/**
|
|
5
|
+
* The largest span, in nanoseconds, whose exact millisecond value a `number` still holds.
|
|
6
|
+
*
|
|
7
|
+
* Guarding here rather than on the truncated whole-millisecond part matters: a span of
|
|
8
|
+
* `MAX_SAFE_INTEGER` milliseconds *plus* a fraction passes a whole-millisecond check and
|
|
9
|
+
* then rounds up to 2^53 on recombination, returning an unsafe integer from a function
|
|
10
|
+
* documented to return the sentinel past the safe range.
|
|
11
|
+
*/
|
|
12
|
+
const MAX_SAFE_NANOSECONDS = BigInt(Number.MAX_SAFE_INTEGER) * NANOSECONDS_PER_MILLISECOND;
|
|
13
|
+
/**
|
|
14
|
+
* Return the exact elapsed milliseconds between two ISO 8601 instant strings.
|
|
15
|
+
*
|
|
16
|
+
* The universal span primitive for profiling and observability. Fractional, like
|
|
17
|
+
* `performance.now()` — a sub-millisecond span is reported as a fraction, not rounded away.
|
|
18
|
+
*
|
|
19
|
+
* - Signed: negative when `start` is after `end`, so `spanMs(b, a)` is exactly
|
|
20
|
+
* `-spanMs(a, b)`.
|
|
21
|
+
* - Measures **exact elapsed time**, never calendar distance. A wall-clock day containing a
|
|
22
|
+
* DST transition is 23 or 25 hours (or 24.5, in `Australia/Lord_Howe`), and `spanMs`
|
|
23
|
+
* reports the hours that actually elapsed. `spanWallClock` answers the calendar question;
|
|
24
|
+
* conflating the two is the most common span bug there is.
|
|
25
|
+
* - Accepts anything `toNanoseconds` does: the full RFC 9557 instant grammar, no leap
|
|
26
|
+
* seconds; calendar and elective annotations are ignored, as `Temporal.Instant.from` ignores
|
|
27
|
+
* them. An offset designator (`Z`, `±HH:MM`) is
|
|
28
|
+
* required, optionally followed by a bracketed IANA zone — a bracket alone is not enough,
|
|
29
|
+
* which is the one string shape `spanWallClock` accepts and these two do not. The
|
|
30
|
+
* endpoints need not share a zone; an instant is an instant.
|
|
31
|
+
* - **A bracketed zone annotation is syntactic only.** As in `Temporal.Instant.from`, it is
|
|
32
|
+
* ignored: each offset alone fixes its instant, and a zone that does not exist or disagrees
|
|
33
|
+
* with the offset is not checked. `spanWallClock`, by contrast, rejects a mismatched offset.
|
|
34
|
+
* - Returns `null` on invalid input, not `0` — `0` is the span between an instant and itself.
|
|
35
|
+
* `null`, not `NaN`, because that is GMT's sentinel for every number-returning function:
|
|
36
|
+
* it is the one a caller already checks for, and the only one `strictNullChecks` forces
|
|
37
|
+
* them to handle. A `NaN` would type as plain `number` and propagate silently through
|
|
38
|
+
* arithmetic. `spanNs` and `spanWallClock` return `null` for the same reason.
|
|
39
|
+
* - **Safe range.** Returns `null` when the exact span exceeds `Number.MAX_SAFE_INTEGER`
|
|
40
|
+
* milliseconds (±9_007_199_254_740_991 ms, about ±285,000 years), which two instants at
|
|
41
|
+
* opposite ends of `Temporal.Instant`'s range do. A sub-millisecond fraction counts
|
|
42
|
+
* toward that ceiling, so any number returned is a safe integer or below. Use `spanNs`
|
|
43
|
+
* past it — it carries the exact value as a `bigint`.
|
|
44
|
+
* Sub-millisecond fidelity goes first, long before the ceiling: a double carries the
|
|
45
|
+
* nanosecond digits exactly only while the span is under 2^53 ns, roughly 104 days.
|
|
46
|
+
* - Leap seconds are not counted. UTC repeats a second rather than numbering a 61st one, so
|
|
47
|
+
* a span across one is a second short of the physical elapsed time; against a smeared
|
|
48
|
+
* clock (Google, AWS, Meta) the error is up to a second spread over the smear window.
|
|
49
|
+
* Leap-second-exact spans need a TAI scale, which GMT does not yet ship.
|
|
50
|
+
*
|
|
51
|
+
* @param start ISO 8601 instant string the span is measured from
|
|
52
|
+
* @param end ISO 8601 instant string the span is measured to
|
|
53
|
+
* @returns exact elapsed milliseconds, negative when start is after end, or null on invalid input
|
|
54
|
+
*
|
|
55
|
+
* @example spanMs("2024-03-10T12:00:00Z", "2024-03-10T12:00:01Z") // 1000
|
|
56
|
+
* @example spanMs("2024-03-10T12:00:01Z", "2024-03-10T12:00:00Z") // -1000
|
|
57
|
+
* @example spanMs("2024-03-10T12:00:00Z", "2024-03-10T12:00:00Z") // 0
|
|
58
|
+
* @example spanMs("2024-03-10T12:00:00Z", "2024-03-10T12:00:00.123456789Z") // 123.456789
|
|
59
|
+
* @example spanMs("2024-03-09T12:00:00-05:00[America/New_York]", "2024-03-10T12:00:00-04:00[America/New_York]") // 82800000 — 23 hours, not 24
|
|
60
|
+
* @example spanMs("2024-03-10T12:00:00+05:00[America/New_York]", "2024-03-10T12:00:00-04:00[America/New_York]") // 32400000 — offsets decide, the zone is ignored
|
|
61
|
+
* @example spanMs("-271821-04-20T00:00:00Z", "+275760-09-13T00:00:00Z") // null — past the safe integer range, use spanNs
|
|
62
|
+
* @example spanMs("2024-03-10T12:00:00Z", "invalid") // null
|
|
63
|
+
*/
|
|
64
|
+
export function spanMs(start, end) {
|
|
65
|
+
const nanoseconds = spanNs(start, end);
|
|
66
|
+
if (nanoseconds === null) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (nanoseconds > MAX_SAFE_NANOSECONDS ||
|
|
70
|
+
nanoseconds < -MAX_SAFE_NANOSECONDS) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
// Split rather than dividing the whole bigint through a double: Number(nanoseconds) is
|
|
74
|
+
// already lossy past 2^53 ns (~104 days), which would corrupt the millisecond part too.
|
|
75
|
+
// BigInt division truncates toward zero and `%` keeps the dividend's sign, so both halves
|
|
76
|
+
// flip together and spanMs(b, a) === -spanMs(a, b) holds exactly.
|
|
77
|
+
const milliseconds = nanoseconds / NANOSECONDS_PER_MILLISECOND;
|
|
78
|
+
const remainder = nanoseconds % NANOSECONDS_PER_MILLISECOND;
|
|
79
|
+
return Number(milliseconds) + Number(remainder) / 1e6;
|
|
80
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the exact elapsed nanoseconds between two ISO 8601 instant strings.
|
|
3
|
+
*
|
|
4
|
+
* The precise form of `spanMs`, and the one to reach for past a `number`'s safe range.
|
|
5
|
+
*
|
|
6
|
+
* - Signed: negative when `start` is after `end`, so `spanNs(b, a)` is exactly
|
|
7
|
+
* `-spanNs(a, b)`.
|
|
8
|
+
* - Measures **exact elapsed time**, never calendar distance. Across a DST transition
|
|
9
|
+
* "one day later" and "24 hours later" are different spans — `spanWallClock` answers
|
|
10
|
+
* the calendar question.
|
|
11
|
+
* - Accepts anything `toNanoseconds` does: the full RFC 9557 instant grammar, no leap
|
|
12
|
+
* seconds; calendar and elective annotations are ignored, as `Temporal.Instant.from` ignores
|
|
13
|
+
* them. An offset designator (`Z`, `±HH:MM`) is
|
|
14
|
+
* required, optionally followed by a bracketed IANA zone — a bracket alone is not enough,
|
|
15
|
+
* which is the one string shape `spanWallClock` accepts and these two do not. The
|
|
16
|
+
* endpoints need not share a zone; an instant is an instant.
|
|
17
|
+
* - **A bracketed zone annotation is syntactic only.** As in `Temporal.Instant.from`, it is
|
|
18
|
+
* ignored: each offset alone fixes its instant, and a zone that does not exist or disagrees
|
|
19
|
+
* with the offset is not checked. `spanWallClock`, by contrast, rejects a mismatched offset.
|
|
20
|
+
* - Returns `null` on invalid input, not `0n` — `0n` is the span between an instant and
|
|
21
|
+
* itself. This is why it does not simply subtract two `toNanoseconds` results, which
|
|
22
|
+
* return `0n` for both the epoch and a rejected string.
|
|
23
|
+
* - The result is a **duration**, not an instant: it ranges up to
|
|
24
|
+
* ±17_280_000_000_000_000_000_000n, twice what `Temporal.Instant` can represent. Do not
|
|
25
|
+
* feed it to `fromNanoseconds`.
|
|
26
|
+
* - Leap seconds are not counted. UTC repeats a second rather than numbering a 61st one, so
|
|
27
|
+
* a span across one is a second short of the physical elapsed time; against a smeared
|
|
28
|
+
* clock (Google, AWS, Meta) the error is up to a second spread over the smear window.
|
|
29
|
+
* Leap-second-exact spans need a TAI scale, which GMT does not yet ship.
|
|
30
|
+
*
|
|
31
|
+
* @param start ISO 8601 instant string the span is measured from
|
|
32
|
+
* @param end ISO 8601 instant string the span is measured to
|
|
33
|
+
* @returns exact elapsed nanoseconds as a bigint, negative when start is after end, or null on invalid input
|
|
34
|
+
*
|
|
35
|
+
* @example spanNs("2024-03-10T12:00:00Z", "2024-03-10T12:00:01Z") // 1000000000n
|
|
36
|
+
* @example spanNs("2024-03-10T12:00:01Z", "2024-03-10T12:00:00Z") // -1000000000n
|
|
37
|
+
* @example spanNs("2024-03-10T12:00:00Z", "2024-03-10T12:00:00Z") // 0n
|
|
38
|
+
* @example spanNs("2024-03-10T12:00:00.123456789Z", "2024-03-10T12:00:00.123456790Z") // 1n
|
|
39
|
+
* @example spanNs("2024-03-10T07:00:00-05:00[America/New_York]", "2024-03-10T12:00:00Z") // 0n — same instant, different zones
|
|
40
|
+
* @example spanNs("2024-03-10T12:00:00+05:00[America/New_York]", "2024-03-10T12:00:00-04:00[America/New_York]") // 32400000000000n — offsets decide, the zone is ignored
|
|
41
|
+
* @example spanNs("2024-03-10T12:00:00Z", "invalid") // null
|
|
42
|
+
*/
|
|
43
|
+
export declare function spanNs(start: string, end: string): bigint | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { parseInstantNanoseconds } from "../../internal/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return the exact elapsed nanoseconds between two ISO 8601 instant strings.
|
|
4
|
+
*
|
|
5
|
+
* The precise form of `spanMs`, and the one to reach for past a `number`'s safe range.
|
|
6
|
+
*
|
|
7
|
+
* - Signed: negative when `start` is after `end`, so `spanNs(b, a)` is exactly
|
|
8
|
+
* `-spanNs(a, b)`.
|
|
9
|
+
* - Measures **exact elapsed time**, never calendar distance. Across a DST transition
|
|
10
|
+
* "one day later" and "24 hours later" are different spans — `spanWallClock` answers
|
|
11
|
+
* the calendar question.
|
|
12
|
+
* - Accepts anything `toNanoseconds` does: the full RFC 9557 instant grammar, no leap
|
|
13
|
+
* seconds; calendar and elective annotations are ignored, as `Temporal.Instant.from` ignores
|
|
14
|
+
* them. An offset designator (`Z`, `±HH:MM`) is
|
|
15
|
+
* required, optionally followed by a bracketed IANA zone — a bracket alone is not enough,
|
|
16
|
+
* which is the one string shape `spanWallClock` accepts and these two do not. The
|
|
17
|
+
* endpoints need not share a zone; an instant is an instant.
|
|
18
|
+
* - **A bracketed zone annotation is syntactic only.** As in `Temporal.Instant.from`, it is
|
|
19
|
+
* ignored: each offset alone fixes its instant, and a zone that does not exist or disagrees
|
|
20
|
+
* with the offset is not checked. `spanWallClock`, by contrast, rejects a mismatched offset.
|
|
21
|
+
* - Returns `null` on invalid input, not `0n` — `0n` is the span between an instant and
|
|
22
|
+
* itself. This is why it does not simply subtract two `toNanoseconds` results, which
|
|
23
|
+
* return `0n` for both the epoch and a rejected string.
|
|
24
|
+
* - The result is a **duration**, not an instant: it ranges up to
|
|
25
|
+
* ±17_280_000_000_000_000_000_000n, twice what `Temporal.Instant` can represent. Do not
|
|
26
|
+
* feed it to `fromNanoseconds`.
|
|
27
|
+
* - Leap seconds are not counted. UTC repeats a second rather than numbering a 61st one, so
|
|
28
|
+
* a span across one is a second short of the physical elapsed time; against a smeared
|
|
29
|
+
* clock (Google, AWS, Meta) the error is up to a second spread over the smear window.
|
|
30
|
+
* Leap-second-exact spans need a TAI scale, which GMT does not yet ship.
|
|
31
|
+
*
|
|
32
|
+
* @param start ISO 8601 instant string the span is measured from
|
|
33
|
+
* @param end ISO 8601 instant string the span is measured to
|
|
34
|
+
* @returns exact elapsed nanoseconds as a bigint, negative when start is after end, or null on invalid input
|
|
35
|
+
*
|
|
36
|
+
* @example spanNs("2024-03-10T12:00:00Z", "2024-03-10T12:00:01Z") // 1000000000n
|
|
37
|
+
* @example spanNs("2024-03-10T12:00:01Z", "2024-03-10T12:00:00Z") // -1000000000n
|
|
38
|
+
* @example spanNs("2024-03-10T12:00:00Z", "2024-03-10T12:00:00Z") // 0n
|
|
39
|
+
* @example spanNs("2024-03-10T12:00:00.123456789Z", "2024-03-10T12:00:00.123456790Z") // 1n
|
|
40
|
+
* @example spanNs("2024-03-10T07:00:00-05:00[America/New_York]", "2024-03-10T12:00:00Z") // 0n — same instant, different zones
|
|
41
|
+
* @example spanNs("2024-03-10T12:00:00+05:00[America/New_York]", "2024-03-10T12:00:00-04:00[America/New_York]") // 32400000000000n — offsets decide, the zone is ignored
|
|
42
|
+
* @example spanNs("2024-03-10T12:00:00Z", "invalid") // null
|
|
43
|
+
*/
|
|
44
|
+
export function spanNs(start, end) {
|
|
45
|
+
const startNanoseconds = parseInstantNanoseconds(start);
|
|
46
|
+
const endNanoseconds = parseInstantNanoseconds(end);
|
|
47
|
+
if (startNanoseconds === null || endNanoseconds === null) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return endNanoseconds - startNanoseconds;
|
|
51
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Units `spanWallClock` measures a calendar distance in.
|
|
3
|
+
*
|
|
4
|
+
* | Unit | Meaning |
|
|
5
|
+
* | --- | --- |
|
|
6
|
+
* | `days` | Whole wall-clock days — a calendar day, whatever number of hours it happened to last. |
|
|
7
|
+
* | `hours` | Whole wall-clock hours — the hours a clock face advanced, not the hours that elapsed. |
|
|
8
|
+
* | `day`, `hour` | The singular names, accepted as Temporal accepts them. |
|
|
9
|
+
*/
|
|
10
|
+
export type WallClockSpanUnit = "days" | "hours" | "day" | "hour";
|
|
11
|
+
/**
|
|
12
|
+
* Return the wall-clock distance between two zoned datetime strings — calendar time, not
|
|
13
|
+
* elapsed time.
|
|
14
|
+
*
|
|
15
|
+
* The counterpart to `spanMs`. Both are correct answers to different questions, and
|
|
16
|
+
* conflating them is the most common span bug there is: across a DST transition "one day
|
|
17
|
+
* later" and "24 hours later" are not the same moment.
|
|
18
|
+
*
|
|
19
|
+
* - Reads each endpoint's own local wall clock and measures between them, so a calendar day
|
|
20
|
+
* is 1 day and 24 hours in every zone, including one whose offset shifted in between.
|
|
21
|
+
* `spanMs` over the same pair reports the 23, 24.5 or 25 hours that actually elapsed.
|
|
22
|
+
* - Truncates toward zero, so the result is a whole count and `spanWallClock(b, a, unit)` is
|
|
23
|
+
* `-spanWallClock(a, b, unit)`. Noon Friday to 18:00 Saturday is 1 day, or 30 hours — ask
|
|
24
|
+
* for `hours` when the remainder matters.
|
|
25
|
+
* - **Not a count of boundaries crossed.** 23:00 to 01:00 the next calendar day is `0` days,
|
|
26
|
+
* not `1`; that question is about local midnights, and is `startOfZoned`'s to answer.
|
|
27
|
+
* - **No disambiguation policy applies, because no local time is converted to an instant.**
|
|
28
|
+
* The wall clock is read straight off the string with `Temporal.PlainDateTime.from`. Going
|
|
29
|
+
* via `ZonedDateTime` would be a local → instant → local round trip, and that round trip is
|
|
30
|
+
* lossy at exactly the DST edges this function exists to get right: an offset-less
|
|
31
|
+
* `"2024-03-10T02:30:00[America/New_York]"` names a wall time that never occurred, and
|
|
32
|
+
* Temporal's default `compatible` disambiguation would silently advance it to `03:30`,
|
|
33
|
+
* turning a 24-hour answer into 23. A nonexistent or ambiguous local time is measured as
|
|
34
|
+
* written instead — for a clock-face question, the digits in the string *are* the answer.
|
|
35
|
+
* - Requires a bracketed IANA time zone on both endpoints, as `isValidZonedDateTime` does —
|
|
36
|
+
* an instant string (`Z`) or a bare offset carries no zone whose wall clock could shift.
|
|
37
|
+
* The offset is optional, but a present one must match the zone. Leap seconds and
|
|
38
|
+
* `[u-ca=...]` calendar annotations are rejected; `days` and `hours` mean the same thing in
|
|
39
|
+
* every calendar system, so the annotation would change nothing.
|
|
40
|
+
* - The endpoints need not share a zone. When they differ, this is the distance between two
|
|
41
|
+
* local wall clocks — a flight leaving New York at 23:00 and landing in Berlin at 11:00 the
|
|
42
|
+
* next local day is 12 wall-clock hours, and 7 elapsed hours by `spanMs`.
|
|
43
|
+
* - Returns `null` on invalid input, not `0` — `0` is the span between a wall time and itself.
|
|
44
|
+
*
|
|
45
|
+
* @param start zoned ISO 8601 datetime string the span is measured from
|
|
46
|
+
* @param end zoned ISO 8601 datetime string the span is measured to
|
|
47
|
+
* @param unit "days" or "hours" (or the singular "day" or "hour") of wall-clock distance
|
|
48
|
+
* @returns whole wall-clock units, negative when start is after end, or null on invalid input
|
|
49
|
+
*
|
|
50
|
+
* @example spanWallClock("2024-03-09T12:00:00-05:00[America/New_York]", "2024-03-10T12:00:00-04:00[America/New_York]", "hours") // 24 — spanMs reports 82800000 (23 hours)
|
|
51
|
+
* @example spanWallClock("2024-11-02T12:00:00-04:00[America/New_York]", "2024-11-03T12:00:00-05:00[America/New_York]", "days") // 1 — spanMs reports 90000000 (25 hours)
|
|
52
|
+
* @example spanWallClock("2024-03-01T12:00:00-05:00[America/New_York]", "2024-03-02T18:00:00-05:00[America/New_York]", "days") // 1 — truncated toward zero
|
|
53
|
+
* @example spanWallClock("2024-03-02T18:00:00-05:00[America/New_York]", "2024-03-01T12:00:00-05:00[America/New_York]", "hours") // -30
|
|
54
|
+
* @example spanWallClock("2024-03-10T23:00:00-04:00[America/New_York]", "2024-03-11T11:00:00+01:00[Europe/Berlin]", "hours") // 12 — each endpoint's own wall clock
|
|
55
|
+
* @example spanWallClock("2024-03-10T02:30:00[America/New_York]", "2024-03-11T02:30:00[America/New_York]", "hours") // 24 — a wall time that never occurred is measured as written
|
|
56
|
+
* @example spanWallClock("2024-03-01T12:00:00-05:00[America/New_York]", "2024-03-02T12:00:00-05:00[America/New_York]", "day") // 1 — singular unit name
|
|
57
|
+
* @example spanWallClock("2024-03-10T12:00:00Z", "2024-03-11T12:00:00Z", "days") // null — no bracketed time zone
|
|
58
|
+
* @example spanWallClock("2024-03-01T12:00:00-05:00[America/New_York]", "2024-03-02T12:00:00-05:00[America/New_York]", "minutes") // null
|
|
59
|
+
*/
|
|
60
|
+
export declare function spanWallClock(start: string, end: string, unit: WallClockSpanUnit): number | null;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { isValidZonedDateTime } from "../../zoned/validate/index.js";
|
|
3
|
+
const WALL_CLOCK_SPAN_UNITS = {
|
|
4
|
+
days: "day",
|
|
5
|
+
hours: "hour",
|
|
6
|
+
day: "day",
|
|
7
|
+
hour: "hour",
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Return the wall-clock distance between two zoned datetime strings — calendar time, not
|
|
11
|
+
* elapsed time.
|
|
12
|
+
*
|
|
13
|
+
* The counterpart to `spanMs`. Both are correct answers to different questions, and
|
|
14
|
+
* conflating them is the most common span bug there is: across a DST transition "one day
|
|
15
|
+
* later" and "24 hours later" are not the same moment.
|
|
16
|
+
*
|
|
17
|
+
* - Reads each endpoint's own local wall clock and measures between them, so a calendar day
|
|
18
|
+
* is 1 day and 24 hours in every zone, including one whose offset shifted in between.
|
|
19
|
+
* `spanMs` over the same pair reports the 23, 24.5 or 25 hours that actually elapsed.
|
|
20
|
+
* - Truncates toward zero, so the result is a whole count and `spanWallClock(b, a, unit)` is
|
|
21
|
+
* `-spanWallClock(a, b, unit)`. Noon Friday to 18:00 Saturday is 1 day, or 30 hours — ask
|
|
22
|
+
* for `hours` when the remainder matters.
|
|
23
|
+
* - **Not a count of boundaries crossed.** 23:00 to 01:00 the next calendar day is `0` days,
|
|
24
|
+
* not `1`; that question is about local midnights, and is `startOfZoned`'s to answer.
|
|
25
|
+
* - **No disambiguation policy applies, because no local time is converted to an instant.**
|
|
26
|
+
* The wall clock is read straight off the string with `Temporal.PlainDateTime.from`. Going
|
|
27
|
+
* via `ZonedDateTime` would be a local → instant → local round trip, and that round trip is
|
|
28
|
+
* lossy at exactly the DST edges this function exists to get right: an offset-less
|
|
29
|
+
* `"2024-03-10T02:30:00[America/New_York]"` names a wall time that never occurred, and
|
|
30
|
+
* Temporal's default `compatible` disambiguation would silently advance it to `03:30`,
|
|
31
|
+
* turning a 24-hour answer into 23. A nonexistent or ambiguous local time is measured as
|
|
32
|
+
* written instead — for a clock-face question, the digits in the string *are* the answer.
|
|
33
|
+
* - Requires a bracketed IANA time zone on both endpoints, as `isValidZonedDateTime` does —
|
|
34
|
+
* an instant string (`Z`) or a bare offset carries no zone whose wall clock could shift.
|
|
35
|
+
* The offset is optional, but a present one must match the zone. Leap seconds and
|
|
36
|
+
* `[u-ca=...]` calendar annotations are rejected; `days` and `hours` mean the same thing in
|
|
37
|
+
* every calendar system, so the annotation would change nothing.
|
|
38
|
+
* - The endpoints need not share a zone. When they differ, this is the distance between two
|
|
39
|
+
* local wall clocks — a flight leaving New York at 23:00 and landing in Berlin at 11:00 the
|
|
40
|
+
* next local day is 12 wall-clock hours, and 7 elapsed hours by `spanMs`.
|
|
41
|
+
* - Returns `null` on invalid input, not `0` — `0` is the span between a wall time and itself.
|
|
42
|
+
*
|
|
43
|
+
* @param start zoned ISO 8601 datetime string the span is measured from
|
|
44
|
+
* @param end zoned ISO 8601 datetime string the span is measured to
|
|
45
|
+
* @param unit "days" or "hours" (or the singular "day" or "hour") of wall-clock distance
|
|
46
|
+
* @returns whole wall-clock units, negative when start is after end, or null on invalid input
|
|
47
|
+
*
|
|
48
|
+
* @example spanWallClock("2024-03-09T12:00:00-05:00[America/New_York]", "2024-03-10T12:00:00-04:00[America/New_York]", "hours") // 24 — spanMs reports 82800000 (23 hours)
|
|
49
|
+
* @example spanWallClock("2024-11-02T12:00:00-04:00[America/New_York]", "2024-11-03T12:00:00-05:00[America/New_York]", "days") // 1 — spanMs reports 90000000 (25 hours)
|
|
50
|
+
* @example spanWallClock("2024-03-01T12:00:00-05:00[America/New_York]", "2024-03-02T18:00:00-05:00[America/New_York]", "days") // 1 — truncated toward zero
|
|
51
|
+
* @example spanWallClock("2024-03-02T18:00:00-05:00[America/New_York]", "2024-03-01T12:00:00-05:00[America/New_York]", "hours") // -30
|
|
52
|
+
* @example spanWallClock("2024-03-10T23:00:00-04:00[America/New_York]", "2024-03-11T11:00:00+01:00[Europe/Berlin]", "hours") // 12 — each endpoint's own wall clock
|
|
53
|
+
* @example spanWallClock("2024-03-10T02:30:00[America/New_York]", "2024-03-11T02:30:00[America/New_York]", "hours") // 24 — a wall time that never occurred is measured as written
|
|
54
|
+
* @example spanWallClock("2024-03-01T12:00:00-05:00[America/New_York]", "2024-03-02T12:00:00-05:00[America/New_York]", "day") // 1 — singular unit name
|
|
55
|
+
* @example spanWallClock("2024-03-10T12:00:00Z", "2024-03-11T12:00:00Z", "days") // null — no bracketed time zone
|
|
56
|
+
* @example spanWallClock("2024-03-01T12:00:00-05:00[America/New_York]", "2024-03-02T12:00:00-05:00[America/New_York]", "minutes") // null
|
|
57
|
+
*/
|
|
58
|
+
export function spanWallClock(start, end, unit) {
|
|
59
|
+
if (typeof unit !== "string") {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (!Object.hasOwn(WALL_CLOCK_SPAN_UNITS, unit) ||
|
|
63
|
+
!isValidZonedDateTime(start) ||
|
|
64
|
+
!isValidZonedDateTime(end)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const startWallClock = Temporal.PlainDateTime.from(start);
|
|
69
|
+
const endWallClock = Temporal.PlainDateTime.from(end);
|
|
70
|
+
const duration = startWallClock.until(endWallClock, {
|
|
71
|
+
largestUnit: WALL_CLOCK_SPAN_UNITS[unit],
|
|
72
|
+
});
|
|
73
|
+
return WALL_CLOCK_SPAN_UNITS[unit] === "day"
|
|
74
|
+
? duration.days
|
|
75
|
+
: duration.hours;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./isValidSpan.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./isValidSpan.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate whether two ISO 8601 instant strings form a measurable span.
|
|
3
|
+
*
|
|
4
|
+
* True exactly when `spanMs` and `spanNs` will return a value rather than `null` — the
|
|
5
|
+
* endpoints both parse, so there is an elapsed time between them.
|
|
6
|
+
*
|
|
7
|
+
* - Accepts what `toNanoseconds` does on both sides: an offset designator is required,
|
|
8
|
+
* optionally followed by a bracketed IANA zone; no leap seconds. Calendar and elective
|
|
9
|
+
* annotations are ignored, as `Temporal.Instant.from` ignores them. The two endpoints need not
|
|
10
|
+
* share a zone.
|
|
11
|
+
* - **A bracketed zone annotation is syntactic only.** As in `Temporal.Instant.from`, it is
|
|
12
|
+
* ignored: each offset alone fixes its instant, and a zone that does not exist or disagrees
|
|
13
|
+
* with the offset is not checked.
|
|
14
|
+
* - Order does not matter. A span is signed, not invalid, when `start` is after `end`, so
|
|
15
|
+
* this is symmetric.
|
|
16
|
+
* - **`spanMs` can still return `null` on a pair this accepts** — a span wider than
|
|
17
|
+
* `Number.MAX_SAFE_INTEGER` milliseconds has no `number` to return. That is a range
|
|
18
|
+
* limit on the result, not a defect in the inputs, and `spanNs` returns the exact
|
|
19
|
+
* `bigint` for the same pair.
|
|
20
|
+
* - Does **not** validate `spanWallClock`, which needs a bracketed IANA zone on both
|
|
21
|
+
* endpoints rather than a bare offset — that is `isValidZonedDateTime`.
|
|
22
|
+
* - Returns `false` for non-strings and empty strings.
|
|
23
|
+
*
|
|
24
|
+
* @param start candidate ISO 8601 instant string the span would be measured from
|
|
25
|
+
* @param end candidate ISO 8601 instant string the span would be measured to
|
|
26
|
+
* @returns boolean indicating whether spanMs/spanNs will measure this pair
|
|
27
|
+
*
|
|
28
|
+
* @example isValidSpan("2024-03-10T12:00:00Z", "2024-03-10T12:00:01Z") // true
|
|
29
|
+
* @example isValidSpan("2024-03-10T12:00:00Z", "2024-03-10T12:00:00Z") // true — a zero span is a span
|
|
30
|
+
* @example isValidSpan("2024-03-10T12:00:01Z", "2024-03-10T12:00:00Z") // true — spans are signed
|
|
31
|
+
* @example isValidSpan("2024-03-10T07:00:00-05:00[America/New_York]", "2024-03-10T12:00:00Z") // true
|
|
32
|
+
* @example isValidSpan("2024-03-10T12:00:00+05:00[America/New_York]", "2024-03-10T12:00:00Z[Not/AZone]") // true — zone annotations are not checked
|
|
33
|
+
* @example isValidSpan("-271821-04-20T00:00:00Z", "+275760-09-13T00:00:00Z") // true — but spanMs returns null, use spanNs
|
|
34
|
+
* @example isValidSpan("2024-03-10T12:00:00Z", "invalid") // false
|
|
35
|
+
* @example isValidSpan("2024-03-10T12:00:00[America/New_York]", "2024-03-11T12:00:00[America/New_York]") // false — no offset designator
|
|
36
|
+
*/
|
|
37
|
+
export declare function isValidSpan(start: string, end: string): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseInstantNanoseconds } from "../../internal/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validate whether two ISO 8601 instant strings form a measurable span.
|
|
4
|
+
*
|
|
5
|
+
* True exactly when `spanMs` and `spanNs` will return a value rather than `null` — the
|
|
6
|
+
* endpoints both parse, so there is an elapsed time between them.
|
|
7
|
+
*
|
|
8
|
+
* - Accepts what `toNanoseconds` does on both sides: an offset designator is required,
|
|
9
|
+
* optionally followed by a bracketed IANA zone; no leap seconds. Calendar and elective
|
|
10
|
+
* annotations are ignored, as `Temporal.Instant.from` ignores them. The two endpoints need not
|
|
11
|
+
* share a zone.
|
|
12
|
+
* - **A bracketed zone annotation is syntactic only.** As in `Temporal.Instant.from`, it is
|
|
13
|
+
* ignored: each offset alone fixes its instant, and a zone that does not exist or disagrees
|
|
14
|
+
* with the offset is not checked.
|
|
15
|
+
* - Order does not matter. A span is signed, not invalid, when `start` is after `end`, so
|
|
16
|
+
* this is symmetric.
|
|
17
|
+
* - **`spanMs` can still return `null` on a pair this accepts** — a span wider than
|
|
18
|
+
* `Number.MAX_SAFE_INTEGER` milliseconds has no `number` to return. That is a range
|
|
19
|
+
* limit on the result, not a defect in the inputs, and `spanNs` returns the exact
|
|
20
|
+
* `bigint` for the same pair.
|
|
21
|
+
* - Does **not** validate `spanWallClock`, which needs a bracketed IANA zone on both
|
|
22
|
+
* endpoints rather than a bare offset — that is `isValidZonedDateTime`.
|
|
23
|
+
* - Returns `false` for non-strings and empty strings.
|
|
24
|
+
*
|
|
25
|
+
* @param start candidate ISO 8601 instant string the span would be measured from
|
|
26
|
+
* @param end candidate ISO 8601 instant string the span would be measured to
|
|
27
|
+
* @returns boolean indicating whether spanMs/spanNs will measure this pair
|
|
28
|
+
*
|
|
29
|
+
* @example isValidSpan("2024-03-10T12:00:00Z", "2024-03-10T12:00:01Z") // true
|
|
30
|
+
* @example isValidSpan("2024-03-10T12:00:00Z", "2024-03-10T12:00:00Z") // true — a zero span is a span
|
|
31
|
+
* @example isValidSpan("2024-03-10T12:00:01Z", "2024-03-10T12:00:00Z") // true — spans are signed
|
|
32
|
+
* @example isValidSpan("2024-03-10T07:00:00-05:00[America/New_York]", "2024-03-10T12:00:00Z") // true
|
|
33
|
+
* @example isValidSpan("2024-03-10T12:00:00+05:00[America/New_York]", "2024-03-10T12:00:00Z[Not/AZone]") // true — zone annotations are not checked
|
|
34
|
+
* @example isValidSpan("-271821-04-20T00:00:00Z", "+275760-09-13T00:00:00Z") // true — but spanMs returns null, use spanNs
|
|
35
|
+
* @example isValidSpan("2024-03-10T12:00:00Z", "invalid") // false
|
|
36
|
+
* @example isValidSpan("2024-03-10T12:00:00[America/New_York]", "2024-03-11T12:00:00[America/New_York]") // false — no offset designator
|
|
37
|
+
*/
|
|
38
|
+
export function isValidSpan(start, end) {
|
|
39
|
+
return (parseInstantNanoseconds(start) !== null &&
|
|
40
|
+
parseInstantNanoseconds(end) !== null);
|
|
41
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** What `dwellTime` returns: exact elapsed time plus the local view every charging regime counts in. */
|
|
2
|
+
export interface Dwell {
|
|
3
|
+
/** Exact elapsed time from entry to exit, as an ISO 8601 duration with hours as the largest unit. */
|
|
4
|
+
duration: string;
|
|
5
|
+
/** The entry, rendered in the dwell zone. */
|
|
6
|
+
enter: string;
|
|
7
|
+
/** The exit, rendered in the dwell zone. */
|
|
8
|
+
exit: string;
|
|
9
|
+
/** Distinct local calendar dates the dwell touched, counted half-open at the exit. */
|
|
10
|
+
calendarDays: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Measure how long something sat somewhere, and how many local calendar days it sat there.
|
|
14
|
+
*
|
|
15
|
+
* Terminals, depots, yards, stations, gates and berths all charge dwell, and none of them
|
|
16
|
+
* charge by elapsed hours. They count the local calendar days the thing was present, so a
|
|
17
|
+
* container that gates in at 23:00 and out at 01:00 has been there two hours and two days.
|
|
18
|
+
* `dwellTime` returns both, and is the one "local days crossed" primitive in the library: free
|
|
19
|
+
* time and demurrage (INT-12), laytime day counts (MAR-19) and hospital length of stay
|
|
20
|
+
* all take their day boundary from here rather than each deciding what a midnight is.
|
|
21
|
+
*
|
|
22
|
+
* - **`duration` is exact elapsed time.** A dwell spanning a DST transition reports the hours
|
|
23
|
+
* that actually elapsed; the local wall clocks at either end can be an hour apart from that.
|
|
24
|
+
* Hours is the largest unit, so the value never depends on a calendar.
|
|
25
|
+
* - **`calendarDays` is not `duration` rounded up.** It is the number of distinct local dates
|
|
26
|
+
* in `targetZone` that the half-open interval `[entry, exit)` touches: entry and exit on the
|
|
27
|
+
* same local date is `1`, across one local midnight is `2`, and so on. A dwell that ends
|
|
28
|
+
* exactly at a local midnight does not touch the new day, because the exit instant itself
|
|
29
|
+
* is excluded — the same half-open rule as `bucketRange` and CORE-6's intervals. A zero-length
|
|
30
|
+
* dwell touches one date. The count walks the zone's real transitions: between two of them
|
|
31
|
+
* the wall clock runs forward without a break, so each stretch touches every date from its
|
|
32
|
+
* first instant to its last, and the count is the size of the union of those dates. A 23- or
|
|
33
|
+
* 25-hour local day is one day, not 0.96 or 1.04 of one; a date the zone deleted is never
|
|
34
|
+
* touched (`Pacific/Apia` skipped 2011-12-30); and a date the clock falls back into is still
|
|
35
|
+
* one date (`America/Goose_Bay` fell back from 00:01 on 7 November 2010 into the 6th).
|
|
36
|
+
* - **The zone decides the count, so it has to be stated.** `targetZone` is used when given.
|
|
37
|
+
* Without it, the entry's bracketed IANA zone is used. As in `Temporal.Instant.from`, a
|
|
38
|
+
* bracketed zone is otherwise not read, so it is not validated either: the entry's is read
|
|
39
|
+
* (and must exist and agree with its offset) only when it supplies the dwell zone, because
|
|
40
|
+
* `targetZone` is omitted, and the exit's is never read. If the entry and exit are bare
|
|
41
|
+
* instants — `Z` or an offset — and no `targetZone` is given, the result is `null`: an
|
|
42
|
+
* offset is not a zone (CORE-4), and a day count in an unstated locality would be a guess.
|
|
43
|
+
* - `enter` and `exit` are the two instants rendered in the dwell zone, so a charging record
|
|
44
|
+
* shows the local times the terminal's own clock showed.
|
|
45
|
+
* - `targetZone` is whatever `isValidTimeZone` accepts, which is what Temporal accepts: an IANA
|
|
46
|
+
* identifier, or a fixed offset such as `"+02:00"`, as `etaAtZone` also takes. Days are then
|
|
47
|
+
* counted in that offset, which observes no DST, so pass the place's IANA zone when there is one.
|
|
48
|
+
* - GMT does not resolve a port, terminal or station code to a zone; the caller supplies the
|
|
49
|
+
* identifier.
|
|
50
|
+
* - Long dwells stay cheap: the walk visits zone transitions, not days. A dwell that crosses
|
|
51
|
+
* more than 10,000 transitions (about 5,000 years of twice-yearly DST) returns `null`.
|
|
52
|
+
* - Returns `null` when either instant is invalid, when `exit` is before `entry` (an inverted
|
|
53
|
+
* dwell is a data error, not a negative stay), or when no zone can be determined.
|
|
54
|
+
*
|
|
55
|
+
* @param entry ISO 8601 zoned datetime or instant string of the gate-in, arrival or admission
|
|
56
|
+
* @param exit ISO 8601 zoned datetime or instant string of the gate-out, departure or discharge
|
|
57
|
+
* @param targetZone IANA timeZone identifier or fixed offset the days are counted in; defaults to `entry`'s bracketed zone
|
|
58
|
+
* @returns exact duration, zone-local entry and exit, and the local calendar days touched, or null on invalid input
|
|
59
|
+
*
|
|
60
|
+
* @example dwellTime("2024-06-15T23:00:00-04:00[America/New_York]", "2024-06-16T01:00:00-04:00[America/New_York]") // { duration: "PT2H", enter: "2024-06-15T23:00:00-04:00[America/New_York]", exit: "2024-06-16T01:00:00-04:00[America/New_York]", calendarDays: 2 }
|
|
61
|
+
* @example dwellTime("2024-06-15T08:00:00Z", "2024-06-15T17:30:00Z", "Europe/Berlin") // { duration: "PT9H30M", enter: "2024-06-15T10:00:00+02:00[Europe/Berlin]", exit: "2024-06-15T19:30:00+02:00[Europe/Berlin]", calendarDays: 1 }
|
|
62
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "Europe/London") // { duration: "PT2H30M", enter: "2024-06-15T23:30:00+01:00[Europe/London]", exit: "2024-06-16T02:00:00+01:00[Europe/London]", calendarDays: 2 }
|
|
63
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "Europe/Amsterdam") // { duration: "PT2H30M", enter: "2024-06-16T00:30:00+02:00[Europe/Amsterdam]", exit: "2024-06-16T03:00:00+02:00[Europe/Amsterdam]", calendarDays: 1 } (the same two instants, one fewer day: the zone decides)
|
|
64
|
+
* @example dwellTime("2024-06-15T22:00:00Z", "2024-06-16T04:00:00Z", "America/New_York") // { duration: "PT6H", enter: "2024-06-15T18:00:00-04:00[America/New_York]", exit: "2024-06-16T00:00:00-04:00[America/New_York]", calendarDays: 1 } (an exit exactly at local midnight does not touch the new day)
|
|
65
|
+
* @example dwellTime("2024-03-10T05:00:00Z", "2024-03-10T12:00:00Z", "America/New_York") // { duration: "PT7H", enter: "2024-03-10T00:00:00-05:00[America/New_York]", exit: "2024-03-10T08:00:00-04:00[America/New_York]", calendarDays: 1 } (seven elapsed hours across the spring-forward, one local day)
|
|
66
|
+
* @example dwellTime("2011-12-30T08:00:00Z", "2011-12-30T11:00:00Z", "Pacific/Apia") // { duration: "PT3H", enter: "2011-12-29T22:00:00-10:00[Pacific/Apia]", exit: "2011-12-31T01:00:00+14:00[Pacific/Apia]", calendarDays: 2 } (29 and 31 December: Samoa deleted the 30th)
|
|
67
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "+02:00") // { duration: "PT2H30M", enter: "2024-06-16T00:30:00+02:00[+02:00]", exit: "2024-06-16T03:00:00+02:00[+02:00]", calendarDays: 1 } (a fixed offset counts days with no DST)
|
|
68
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z") // null (bare instants and no zone: the day count has no locality)
|
|
69
|
+
* @example dwellTime("2024-06-16T01:00:00Z", "2024-06-15T22:30:00Z", "Europe/London") // null (exit before entry)
|
|
70
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "Europe/Londres") // null
|
|
71
|
+
*/
|
|
72
|
+
export declare function dwellTime(entry: string, exit: string, targetZone?: string): Dwell | null;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { countZonedLocalDates, zonedDateTimeFrom } from "../../internal/index.js";
|
|
3
|
+
import { isValidInstant } from "../../precision/validate/isValidInstant.js";
|
|
4
|
+
import { isValidTimeZone } from "../../zoned/validate/isValidTimeZone.js";
|
|
5
|
+
import { isValidZonedDateTime } from "../../zoned/validate/isValidZonedDateTime.js";
|
|
6
|
+
/**
|
|
7
|
+
* The zone a dwell is counted in: the caller's, or the one the entry string carries.
|
|
8
|
+
*
|
|
9
|
+
* An entry written with a bracketed IANA zone names a place; `Z` and offset-only strings name a
|
|
10
|
+
* moment and nothing else, so with no `targetZone` there is no locality to count days in.
|
|
11
|
+
*/
|
|
12
|
+
function dwellZone(entry, targetZone) {
|
|
13
|
+
if (targetZone !== undefined) {
|
|
14
|
+
return isValidTimeZone(targetZone) ? targetZone : null;
|
|
15
|
+
}
|
|
16
|
+
if (!isValidZonedDateTime(entry)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return zonedDateTimeFrom(entry).timeZoneId;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Measure how long something sat somewhere, and how many local calendar days it sat there.
|
|
28
|
+
*
|
|
29
|
+
* Terminals, depots, yards, stations, gates and berths all charge dwell, and none of them
|
|
30
|
+
* charge by elapsed hours. They count the local calendar days the thing was present, so a
|
|
31
|
+
* container that gates in at 23:00 and out at 01:00 has been there two hours and two days.
|
|
32
|
+
* `dwellTime` returns both, and is the one "local days crossed" primitive in the library: free
|
|
33
|
+
* time and demurrage (INT-12), laytime day counts (MAR-19) and hospital length of stay
|
|
34
|
+
* all take their day boundary from here rather than each deciding what a midnight is.
|
|
35
|
+
*
|
|
36
|
+
* - **`duration` is exact elapsed time.** A dwell spanning a DST transition reports the hours
|
|
37
|
+
* that actually elapsed; the local wall clocks at either end can be an hour apart from that.
|
|
38
|
+
* Hours is the largest unit, so the value never depends on a calendar.
|
|
39
|
+
* - **`calendarDays` is not `duration` rounded up.** It is the number of distinct local dates
|
|
40
|
+
* in `targetZone` that the half-open interval `[entry, exit)` touches: entry and exit on the
|
|
41
|
+
* same local date is `1`, across one local midnight is `2`, and so on. A dwell that ends
|
|
42
|
+
* exactly at a local midnight does not touch the new day, because the exit instant itself
|
|
43
|
+
* is excluded — the same half-open rule as `bucketRange` and CORE-6's intervals. A zero-length
|
|
44
|
+
* dwell touches one date. The count walks the zone's real transitions: between two of them
|
|
45
|
+
* the wall clock runs forward without a break, so each stretch touches every date from its
|
|
46
|
+
* first instant to its last, and the count is the size of the union of those dates. A 23- or
|
|
47
|
+
* 25-hour local day is one day, not 0.96 or 1.04 of one; a date the zone deleted is never
|
|
48
|
+
* touched (`Pacific/Apia` skipped 2011-12-30); and a date the clock falls back into is still
|
|
49
|
+
* one date (`America/Goose_Bay` fell back from 00:01 on 7 November 2010 into the 6th).
|
|
50
|
+
* - **The zone decides the count, so it has to be stated.** `targetZone` is used when given.
|
|
51
|
+
* Without it, the entry's bracketed IANA zone is used. As in `Temporal.Instant.from`, a
|
|
52
|
+
* bracketed zone is otherwise not read, so it is not validated either: the entry's is read
|
|
53
|
+
* (and must exist and agree with its offset) only when it supplies the dwell zone, because
|
|
54
|
+
* `targetZone` is omitted, and the exit's is never read. If the entry and exit are bare
|
|
55
|
+
* instants — `Z` or an offset — and no `targetZone` is given, the result is `null`: an
|
|
56
|
+
* offset is not a zone (CORE-4), and a day count in an unstated locality would be a guess.
|
|
57
|
+
* - `enter` and `exit` are the two instants rendered in the dwell zone, so a charging record
|
|
58
|
+
* shows the local times the terminal's own clock showed.
|
|
59
|
+
* - `targetZone` is whatever `isValidTimeZone` accepts, which is what Temporal accepts: an IANA
|
|
60
|
+
* identifier, or a fixed offset such as `"+02:00"`, as `etaAtZone` also takes. Days are then
|
|
61
|
+
* counted in that offset, which observes no DST, so pass the place's IANA zone when there is one.
|
|
62
|
+
* - GMT does not resolve a port, terminal or station code to a zone; the caller supplies the
|
|
63
|
+
* identifier.
|
|
64
|
+
* - Long dwells stay cheap: the walk visits zone transitions, not days. A dwell that crosses
|
|
65
|
+
* more than 10,000 transitions (about 5,000 years of twice-yearly DST) returns `null`.
|
|
66
|
+
* - Returns `null` when either instant is invalid, when `exit` is before `entry` (an inverted
|
|
67
|
+
* dwell is a data error, not a negative stay), or when no zone can be determined.
|
|
68
|
+
*
|
|
69
|
+
* @param entry ISO 8601 zoned datetime or instant string of the gate-in, arrival or admission
|
|
70
|
+
* @param exit ISO 8601 zoned datetime or instant string of the gate-out, departure or discharge
|
|
71
|
+
* @param targetZone IANA timeZone identifier or fixed offset the days are counted in; defaults to `entry`'s bracketed zone
|
|
72
|
+
* @returns exact duration, zone-local entry and exit, and the local calendar days touched, or null on invalid input
|
|
73
|
+
*
|
|
74
|
+
* @example dwellTime("2024-06-15T23:00:00-04:00[America/New_York]", "2024-06-16T01:00:00-04:00[America/New_York]") // { duration: "PT2H", enter: "2024-06-15T23:00:00-04:00[America/New_York]", exit: "2024-06-16T01:00:00-04:00[America/New_York]", calendarDays: 2 }
|
|
75
|
+
* @example dwellTime("2024-06-15T08:00:00Z", "2024-06-15T17:30:00Z", "Europe/Berlin") // { duration: "PT9H30M", enter: "2024-06-15T10:00:00+02:00[Europe/Berlin]", exit: "2024-06-15T19:30:00+02:00[Europe/Berlin]", calendarDays: 1 }
|
|
76
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "Europe/London") // { duration: "PT2H30M", enter: "2024-06-15T23:30:00+01:00[Europe/London]", exit: "2024-06-16T02:00:00+01:00[Europe/London]", calendarDays: 2 }
|
|
77
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "Europe/Amsterdam") // { duration: "PT2H30M", enter: "2024-06-16T00:30:00+02:00[Europe/Amsterdam]", exit: "2024-06-16T03:00:00+02:00[Europe/Amsterdam]", calendarDays: 1 } (the same two instants, one fewer day: the zone decides)
|
|
78
|
+
* @example dwellTime("2024-06-15T22:00:00Z", "2024-06-16T04:00:00Z", "America/New_York") // { duration: "PT6H", enter: "2024-06-15T18:00:00-04:00[America/New_York]", exit: "2024-06-16T00:00:00-04:00[America/New_York]", calendarDays: 1 } (an exit exactly at local midnight does not touch the new day)
|
|
79
|
+
* @example dwellTime("2024-03-10T05:00:00Z", "2024-03-10T12:00:00Z", "America/New_York") // { duration: "PT7H", enter: "2024-03-10T00:00:00-05:00[America/New_York]", exit: "2024-03-10T08:00:00-04:00[America/New_York]", calendarDays: 1 } (seven elapsed hours across the spring-forward, one local day)
|
|
80
|
+
* @example dwellTime("2011-12-30T08:00:00Z", "2011-12-30T11:00:00Z", "Pacific/Apia") // { duration: "PT3H", enter: "2011-12-29T22:00:00-10:00[Pacific/Apia]", exit: "2011-12-31T01:00:00+14:00[Pacific/Apia]", calendarDays: 2 } (29 and 31 December: Samoa deleted the 30th)
|
|
81
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "+02:00") // { duration: "PT2H30M", enter: "2024-06-16T00:30:00+02:00[+02:00]", exit: "2024-06-16T03:00:00+02:00[+02:00]", calendarDays: 1 } (a fixed offset counts days with no DST)
|
|
82
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z") // null (bare instants and no zone: the day count has no locality)
|
|
83
|
+
* @example dwellTime("2024-06-16T01:00:00Z", "2024-06-15T22:30:00Z", "Europe/London") // null (exit before entry)
|
|
84
|
+
* @example dwellTime("2024-06-15T22:30:00Z", "2024-06-16T01:00:00Z", "Europe/Londres") // null
|
|
85
|
+
*/
|
|
86
|
+
export function dwellTime(entry, exit, targetZone) {
|
|
87
|
+
try {
|
|
88
|
+
if (!isValidInstant(entry) || !isValidInstant(exit)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const zone = dwellZone(entry, targetZone);
|
|
92
|
+
if (zone === null) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const entryInstant = Temporal.Instant.from(entry);
|
|
96
|
+
const exitInstant = Temporal.Instant.from(exit);
|
|
97
|
+
if (Temporal.Instant.compare(entryInstant, exitInstant) > 0) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const enter = entryInstant.toZonedDateTimeISO(zone);
|
|
101
|
+
const leave = exitInstant.toZonedDateTimeISO(zone);
|
|
102
|
+
// Half-open at the exit: the dwell's last instant is one nanosecond before it, so an exit
|
|
103
|
+
// exactly on a local day boundary does not touch the new day. A zero-length dwell still
|
|
104
|
+
// touches the one date it sits on.
|
|
105
|
+
const last = Temporal.Instant.compare(entryInstant, exitInstant) < 0
|
|
106
|
+
? leave.subtract({ nanoseconds: 1 })
|
|
107
|
+
: leave;
|
|
108
|
+
const calendarDays = countZonedLocalDates(enter, last);
|
|
109
|
+
if (calendarDays === null) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
duration: entryInstant
|
|
114
|
+
.until(exitInstant, { largestUnit: "hours" })
|
|
115
|
+
.toString(),
|
|
116
|
+
enter: enter.toString(),
|
|
117
|
+
exit: leave.toString(),
|
|
118
|
+
calendarDays,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Never throws (Core Rule 3): a hostile
|
|
123
|
+
// argument is invalid input, not an exception.
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|