@northguild/gmt 1.18.0 → 1.20.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 +55 -2920
- package/dist/calendar/business/businessDaysBetween.d.ts +2 -2
- package/dist/calendar/business/businessDaysBetween.js +11 -35
- package/dist/calendar/business/mergeCalendars.d.ts +1 -1
- package/dist/calendar/business/mergeCalendars.js +8 -9
- package/dist/calendar/business/nextBusinessDay.d.ts +2 -2
- package/dist/calendar/business/nextBusinessDay.js +2 -2
- package/dist/calendar/business/previousBusinessDay.d.ts +2 -2
- package/dist/calendar/business/previousBusinessDay.js +2 -2
- package/dist/calendar/business/rollDate.d.ts +3 -3
- package/dist/calendar/business/rollDate.js +10 -43
- package/dist/calendar/calculate/bucketRange.d.ts +19 -11
- package/dist/calendar/calculate/bucketRange.js +27 -70
- package/dist/calendar/calculate/floorToZone.d.ts +12 -4
- package/dist/calendar/calculate/floorToZone.js +16 -8
- package/dist/calendar/calculate/getFiscalPeriod.d.ts +50 -40
- package/dist/calendar/calculate/getFiscalPeriod.js +78 -57
- package/dist/calendar/calculate/getQuarter.d.ts +26 -21
- package/dist/calendar/calculate/getQuarter.js +48 -19
- package/dist/calendar/hours/addOperatingTime.d.ts +9 -3
- package/dist/calendar/hours/addOperatingTime.js +10 -4
- package/dist/calendar/hours/isOpenAt.d.ts +9 -3
- package/dist/calendar/hours/isOpenAt.js +9 -3
- package/dist/calendar/hours/nextCloseAt.d.ts +8 -2
- package/dist/calendar/hours/nextCloseAt.js +9 -3
- package/dist/calendar/hours/nextOpenAt.d.ts +9 -3
- package/dist/calendar/hours/nextOpenAt.js +10 -4
- package/dist/calendar/hours/operatingIntervals.d.ts +7 -2
- package/dist/calendar/hours/operatingIntervals.js +9 -6
- package/dist/calendar/hours/operatingTimeBetween.d.ts +8 -3
- package/dist/calendar/hours/operatingTimeBetween.js +11 -8
- package/dist/calendar/hours/recurringWindows.d.ts +13 -6
- package/dist/calendar/hours/recurringWindows.js +21 -14
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/index.js +2 -2
- package/dist/calendar/validate/index.d.ts +3 -0
- package/dist/calendar/validate/index.js +3 -0
- package/dist/calendar/validate/isValidFiscalCalendar.d.ts +23 -0
- package/dist/calendar/validate/isValidFiscalCalendar.js +44 -0
- package/dist/calendar/validate/isValidFiscalExtraWeek.d.ts +19 -0
- package/dist/calendar/validate/isValidFiscalExtraWeek.js +23 -0
- package/dist/calendar/validate/isValidFiscalPattern.d.ts +7 -7
- package/dist/calendar/validate/isValidFiscalPattern.js +7 -7
- package/dist/calendar/validate/isValidFiscalYearLabel.d.ts +20 -0
- package/dist/calendar/validate/isValidFiscalYearLabel.js +24 -0
- package/dist/calendar/validate/isValidRollConvention.js +2 -10
- package/dist/calendar/validate/isValidZoneBucketUnit.d.ts +1 -1
- package/dist/duration/calculate/absDuration.js +1 -1
- package/dist/duration/calculate/addDuration.js +1 -1
- package/dist/duration/calculate/durationFromUnits.d.ts +47 -0
- package/dist/duration/calculate/durationFromUnits.js +67 -0
- package/dist/duration/calculate/getDurationSign.js +1 -1
- package/dist/duration/calculate/getDurationUnit.d.ts +3 -3
- package/dist/duration/calculate/getDurationUnit.js +3 -3
- package/dist/duration/calculate/index.d.ts +3 -1
- package/dist/duration/calculate/index.js +3 -1
- package/dist/duration/calculate/negateDuration.d.ts +1 -1
- package/dist/duration/calculate/negateDuration.js +2 -2
- package/dist/duration/calculate/subtractDuration.js +1 -1
- package/dist/duration/calculate/{durationAs.d.ts → totalDuration.d.ts} +27 -21
- package/dist/duration/calculate/{durationAs.js → totalDuration.js} +27 -21
- package/dist/duration/calculate/totalUnits.d.ts +49 -0
- package/dist/duration/calculate/totalUnits.js +73 -0
- package/dist/duration/compare/compareDurations.d.ts +4 -4
- package/dist/duration/compare/compareDurations.js +4 -4
- package/dist/duration/format/formatDuration.d.ts +9 -9
- package/dist/duration/format/formatDuration.js +14 -13
- package/dist/duration/index.d.ts +1 -1
- package/dist/duration/index.js +2 -2
- package/dist/duration/normalize/normalizeDuration.d.ts +3 -3
- package/dist/duration/normalize/normalizeDuration.js +3 -3
- package/dist/duration/parse/parseDuration.d.ts +1 -1
- package/dist/duration/parse/parseDuration.js +1 -1
- package/dist/duration/validate/isValidDuration.js +2 -11
- package/dist/gnss/convert/gnssToUtc.d.ts +24 -0
- package/dist/gnss/convert/gnssToUtc.js +39 -0
- package/dist/gnss/convert/gnssWeekToUtc.d.ts +53 -0
- package/dist/gnss/convert/gnssWeekToUtc.js +80 -0
- package/dist/gnss/convert/index.d.ts +6 -0
- package/dist/gnss/convert/index.js +6 -0
- package/dist/gnss/convert/rinexWeekToUtc.d.ts +34 -0
- package/dist/gnss/convert/rinexWeekToUtc.js +57 -0
- package/dist/gnss/convert/utcToGnss.d.ts +38 -0
- package/dist/gnss/convert/utcToGnss.js +53 -0
- package/dist/gnss/convert/utcToGnssWeek.d.ts +24 -0
- package/dist/gnss/convert/utcToGnssWeek.js +40 -0
- package/dist/gnss/convert/utcToRinexWeek.d.ts +19 -0
- package/dist/gnss/convert/utcToRinexWeek.js +45 -0
- package/dist/gnss/index.d.ts +2 -0
- package/dist/gnss/index.js +3 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/instant/convert/classifyLocal.d.ts +9 -5
- package/dist/instant/convert/classifyLocal.js +19 -20
- package/dist/instant/convert/fromOffsetInstant.d.ts +8 -4
- package/dist/instant/convert/fromOffsetInstant.js +11 -6
- package/dist/instant/convert/resolveLocal.d.ts +16 -11
- package/dist/instant/convert/resolveLocal.js +25 -17
- package/dist/instant/convert/toOffsetInstant.d.ts +23 -19
- package/dist/instant/convert/toOffsetInstant.js +29 -38
- package/dist/instant/index.d.ts +2 -1
- package/dist/instant/index.js +3 -2
- package/dist/instant/validate/index.d.ts +1 -0
- package/dist/instant/validate/index.js +1 -0
- package/dist/instant/validate/isValidUtcOffset.d.ts +32 -0
- package/dist/instant/validate/isValidUtcOffset.js +35 -0
- package/dist/intermodal/calculate/billingTimeline.js +1 -1
- package/dist/intermodal/calculate/chargeableDays.d.ts +18 -12
- package/dist/intermodal/calculate/chargeableDays.js +27 -18
- package/dist/intermodal/calculate/demurrageClock.d.ts +1 -1
- package/dist/intermodal/calculate/demurrageClock.js +2 -2
- package/dist/intermodal/calculate/freeTimeExpiry.d.ts +17 -10
- package/dist/intermodal/calculate/freeTimeExpiry.js +32 -17
- package/dist/intermodal/calculate/index.d.ts +1 -0
- package/dist/intermodal/calculate/index.js +1 -0
- package/dist/intermodal/calculate/multimodalETA.d.ts +76 -0
- package/dist/intermodal/calculate/multimodalETA.js +145 -0
- package/dist/intermodal/format/bolTimestamp.d.ts +76 -0
- package/dist/intermodal/format/bolTimestamp.js +78 -0
- package/dist/intermodal/format/formatEdifactDate.d.ts +34 -0
- package/dist/intermodal/format/formatEdifactDate.js +42 -0
- package/dist/intermodal/format/formatEdifactDatePeriod.d.ts +35 -0
- package/dist/intermodal/format/formatEdifactDatePeriod.js +43 -0
- package/dist/intermodal/format/formatEdifactDateTime.d.ts +37 -0
- package/dist/intermodal/format/formatEdifactDateTime.js +45 -0
- package/dist/intermodal/format/formatEdifactDateTimePeriod.d.ts +40 -0
- package/dist/intermodal/format/formatEdifactDateTimePeriod.js +48 -0
- package/dist/intermodal/format/formatEdifactOffsetDateTime.d.ts +62 -0
- package/dist/intermodal/format/formatEdifactOffsetDateTime.js +70 -0
- package/dist/intermodal/format/formatEdifactTime.d.ts +35 -0
- package/dist/intermodal/format/formatEdifactTime.js +43 -0
- package/dist/intermodal/format/formatEpcisEvent.d.ts +47 -0
- package/dist/intermodal/format/formatEpcisEvent.js +79 -0
- package/dist/intermodal/format/formatX12Date.d.ts +35 -0
- package/dist/intermodal/format/formatX12Date.js +43 -0
- package/dist/intermodal/format/formatX12DateRange.d.ts +37 -0
- package/dist/intermodal/format/formatX12DateRange.js +45 -0
- package/dist/intermodal/format/formatX12DateTime.d.ts +39 -0
- package/dist/intermodal/format/formatX12DateTime.js +47 -0
- package/dist/intermodal/format/formatX12DateTimeRange.d.ts +40 -0
- package/dist/intermodal/format/formatX12DateTimeRange.js +48 -0
- package/dist/intermodal/format/formatX12Time.d.ts +42 -0
- package/dist/intermodal/format/formatX12Time.js +50 -0
- package/dist/intermodal/format/formatX12TimeElement.d.ts +46 -0
- package/dist/intermodal/format/formatX12TimeElement.js +54 -0
- package/dist/intermodal/format/index.d.ts +14 -0
- package/dist/intermodal/format/index.js +14 -0
- package/dist/intermodal/index.d.ts +4 -1
- package/dist/intermodal/index.js +5 -2
- package/dist/intermodal/parse/classifyEdifactDtmFormat.d.ts +48 -0
- package/dist/intermodal/parse/classifyEdifactDtmFormat.js +55 -0
- package/dist/intermodal/parse/classifyX12DateTimePeriodFormat.d.ts +50 -0
- package/dist/intermodal/parse/classifyX12DateTimePeriodFormat.js +57 -0
- package/dist/intermodal/parse/classifyX12TimeCode.d.ts +46 -0
- package/dist/intermodal/parse/classifyX12TimeCode.js +57 -0
- package/dist/intermodal/parse/index.d.ts +18 -0
- package/dist/intermodal/parse/index.js +18 -0
- package/dist/intermodal/parse/parseEdifactDate.d.ts +37 -0
- package/dist/intermodal/parse/parseEdifactDate.js +45 -0
- package/dist/intermodal/parse/parseEdifactDatePeriod.d.ts +43 -0
- package/dist/intermodal/parse/parseEdifactDatePeriod.js +51 -0
- package/dist/intermodal/parse/parseEdifactDateTime.d.ts +43 -0
- package/dist/intermodal/parse/parseEdifactDateTime.js +51 -0
- package/dist/intermodal/parse/parseEdifactDateTimePeriod.d.ts +45 -0
- package/dist/intermodal/parse/parseEdifactDateTimePeriod.js +53 -0
- package/dist/intermodal/parse/parseEdifactOffsetDateTime.d.ts +60 -0
- package/dist/intermodal/parse/parseEdifactOffsetDateTime.js +68 -0
- package/dist/intermodal/parse/parseEdifactTime.d.ts +37 -0
- package/dist/intermodal/parse/parseEdifactTime.js +45 -0
- package/dist/intermodal/parse/parseEpcisEvent.d.ts +95 -0
- package/dist/intermodal/parse/parseEpcisEvent.js +102 -0
- package/dist/intermodal/parse/parseX12Date.d.ts +39 -0
- package/dist/intermodal/parse/parseX12Date.js +47 -0
- package/dist/intermodal/parse/parseX12DateAndTime.d.ts +52 -0
- package/dist/intermodal/parse/parseX12DateAndTime.js +61 -0
- package/dist/intermodal/parse/parseX12DateRange.d.ts +44 -0
- package/dist/intermodal/parse/parseX12DateRange.js +52 -0
- package/dist/intermodal/parse/parseX12DateTime.d.ts +45 -0
- package/dist/intermodal/parse/parseX12DateTime.js +53 -0
- package/dist/intermodal/parse/parseX12DateTimeRange.d.ts +46 -0
- package/dist/intermodal/parse/parseX12DateTimeRange.js +54 -0
- package/dist/intermodal/parse/parseX12Time.d.ts +65 -0
- package/dist/intermodal/parse/parseX12Time.js +77 -0
- package/dist/intermodal/parse/x12TimeCodeOffset.d.ts +57 -0
- package/dist/intermodal/parse/x12TimeCodeOffset.js +110 -0
- package/dist/intermodal/parse/x12TimeCodeZone.d.ts +57 -0
- package/dist/intermodal/parse/x12TimeCodeZone.js +105 -0
- package/dist/intermodal/validate/index.d.ts +18 -0
- package/dist/intermodal/validate/index.js +18 -0
- package/dist/intermodal/validate/isValidEdifactDate.d.ts +26 -0
- package/dist/intermodal/validate/isValidEdifactDate.js +28 -0
- package/dist/intermodal/validate/isValidEdifactDatePeriod.d.ts +28 -0
- package/dist/intermodal/validate/isValidEdifactDatePeriod.js +30 -0
- package/dist/intermodal/validate/isValidEdifactDateTime.d.ts +30 -0
- package/dist/intermodal/validate/isValidEdifactDateTime.js +32 -0
- package/dist/intermodal/validate/isValidEdifactDateTimePeriod.d.ts +28 -0
- package/dist/intermodal/validate/isValidEdifactDateTimePeriod.js +30 -0
- package/dist/intermodal/validate/isValidEdifactDtmFormat.d.ts +39 -0
- package/dist/intermodal/validate/isValidEdifactDtmFormat.js +42 -0
- package/dist/intermodal/validate/isValidEdifactOffsetDateTime.d.ts +36 -0
- package/dist/intermodal/validate/isValidEdifactOffsetDateTime.js +38 -0
- package/dist/intermodal/validate/isValidEdifactTime.d.ts +28 -0
- package/dist/intermodal/validate/isValidEdifactTime.js +30 -0
- package/dist/intermodal/validate/isValidEpcisEvent.d.ts +41 -0
- package/dist/intermodal/validate/isValidEpcisEvent.js +58 -0
- package/dist/intermodal/validate/isValidEpcisEventTime.d.ts +33 -0
- package/dist/intermodal/validate/isValidEpcisEventTime.js +48 -0
- package/dist/intermodal/validate/isValidEpcisTimeZoneOffset.d.ts +30 -0
- package/dist/intermodal/validate/isValidEpcisTimeZoneOffset.js +38 -0
- package/dist/intermodal/validate/isValidX12Date.d.ts +28 -0
- package/dist/intermodal/validate/isValidX12Date.js +30 -0
- package/dist/intermodal/validate/isValidX12DateAndTime.d.ts +32 -0
- package/dist/intermodal/validate/isValidX12DateAndTime.js +35 -0
- package/dist/intermodal/validate/isValidX12DateRange.d.ts +29 -0
- package/dist/intermodal/validate/isValidX12DateRange.js +31 -0
- package/dist/intermodal/validate/isValidX12DateTime.d.ts +30 -0
- package/dist/intermodal/validate/isValidX12DateTime.js +32 -0
- package/dist/intermodal/validate/isValidX12DateTimePeriodFormat.d.ts +43 -0
- package/dist/intermodal/validate/isValidX12DateTimePeriodFormat.js +46 -0
- package/dist/intermodal/validate/isValidX12DateTimeRange.d.ts +31 -0
- package/dist/intermodal/validate/isValidX12DateTimeRange.js +33 -0
- package/dist/intermodal/validate/isValidX12Time.d.ts +38 -0
- package/dist/intermodal/validate/isValidX12Time.js +40 -0
- package/dist/intermodal/validate/isValidX12TimeCode.d.ts +38 -0
- package/dist/intermodal/validate/isValidX12TimeCode.js +41 -0
- package/dist/internal/advanceToWeekday.d.ts +1 -1
- package/dist/internal/businessCalendar.d.ts +28 -12
- package/dist/internal/businessCalendar.js +131 -125
- package/dist/internal/businessDayValues.js +1 -1
- package/dist/internal/calendarDatePairPolicy.d.ts +1 -1
- package/dist/internal/calendarDateString.d.ts +1 -1
- package/dist/internal/calendarDateString.js +1 -1
- package/dist/internal/calendarSystemIds.js +1 -1
- package/dist/internal/calendarValueOfDate.js +1 -1
- package/dist/internal/calendarZonedPairPolicy.d.ts +1 -1
- package/dist/internal/calendarZonedString.d.ts +3 -3
- package/dist/internal/calendarZonedString.js +4 -4
- package/dist/internal/compareUnixEpochs.js +1 -1
- package/dist/internal/cutoffAtResolved.d.ts +62 -0
- package/dist/internal/cutoffAtResolved.js +162 -0
- package/dist/internal/cycleFieldValue.d.ts +0 -2
- package/dist/internal/cycleFieldValue.js +0 -2
- package/dist/internal/dateTimeUnitHelpers.d.ts +1 -1
- package/dist/internal/dateUnitHelpers.d.ts +1 -1
- package/dist/internal/daylightTime.d.ts +1 -1
- package/dist/internal/differenceRecord.d.ts +1 -1
- package/dist/internal/durationUntilString.d.ts +1 -1
- package/dist/internal/durationUntilString.js +1 -1
- package/dist/internal/dutyEngine.d.ts +125 -0
- package/dist/internal/dutyEngine.js +1755 -0
- package/dist/internal/dutyLog.d.ts +27 -0
- package/dist/internal/dutyLog.js +47 -0
- package/dist/internal/dutyPeriods.d.ts +135 -0
- package/dist/internal/dutyPeriods.js +375 -0
- package/dist/internal/dutyRules.d.ts +198 -0
- package/dist/internal/dutyRules.js +484 -0
- package/dist/internal/dutyRunIndex.d.ts +150 -0
- package/dist/internal/dutyRunIndex.js +398 -0
- package/dist/internal/earlierOccurrence.d.ts +41 -0
- package/dist/internal/earlierOccurrence.js +57 -0
- package/dist/internal/ediDateTimeFields.d.ts +97 -0
- package/dist/internal/ediDateTimeFields.js +288 -0
- package/dist/internal/ediDateTimeWriter.d.ts +92 -0
- package/dist/internal/ediDateTimeWriter.js +298 -0
- package/dist/internal/ediGrammar.d.ts +158 -0
- package/dist/internal/ediGrammar.js +384 -0
- package/dist/internal/englishCalendarNames.d.ts +4 -2
- package/dist/internal/englishCalendarNames.js +3 -1
- package/dist/internal/epochDay.d.ts +41 -0
- package/dist/internal/epochDay.js +129 -0
- package/dist/internal/exactDuration.js +1 -1
- package/dist/internal/exactMoment.d.ts +4 -4
- package/dist/internal/exactMoment.js +5 -5
- package/dist/internal/fiscalCalendar.d.ts +41 -7
- package/dist/internal/fiscalCalendar.js +77 -9
- package/dist/internal/foreignEpochs.d.ts +5 -0
- package/dist/internal/foreignEpochs.js +5 -0
- package/dist/internal/formatCalendarDays.d.ts +4 -4
- package/dist/internal/formatCalendarDays.js +6 -5
- package/dist/internal/formatDateInCalendar.d.ts +1 -1
- package/dist/internal/formatRelativeDuration.d.ts +7 -7
- package/dist/internal/formatRelativeDuration.js +8 -7
- package/dist/internal/formatterCache.d.ts +40 -0
- package/dist/internal/formatterCache.js +181 -0
- package/dist/internal/freeTimeLedger.d.ts +35 -42
- package/dist/internal/freeTimeLedger.js +332 -31
- package/dist/internal/getLocaleWeekYearBounds.d.ts +1 -1
- package/dist/internal/gnssTimeScales.d.ts +53 -0
- package/dist/internal/gnssTimeScales.js +128 -0
- package/dist/internal/gnssWeek.d.ts +92 -0
- package/dist/internal/gnssWeek.js +212 -0
- package/dist/internal/halfOpenIntervals.d.ts +1 -1
- package/dist/internal/halfOpenIntervals.js +1 -1
- package/dist/internal/hasCalendarAnnotation.d.ts +3 -3
- package/dist/internal/hasCalendarAnnotation.js +3 -3
- package/dist/internal/hourDurationString.js +1 -1
- package/dist/internal/httpDateFields.js +1 -1
- package/dist/internal/index.d.ts +14 -5
- package/dist/internal/index.js +18 -5
- package/dist/internal/inputChecks.d.ts +53 -0
- package/dist/internal/inputChecks.js +132 -0
- package/dist/internal/instantFormatOptions.d.ts +1 -1
- package/dist/internal/instantFormatOptions.js +4 -8
- package/dist/internal/instantIntervalText.js +1 -1
- package/dist/internal/instantNanoseconds.d.ts +2 -2
- package/dist/internal/instantNanoseconds.js +2 -2
- package/dist/internal/intervalCountHelpers.d.ts +1 -1
- package/dist/internal/intervalNanoseconds.js +2 -1
- package/dist/internal/isObject.d.ts +13 -6
- package/dist/internal/isObject.js +14 -7
- package/dist/internal/isoStringBody.d.ts +2 -2
- package/dist/internal/isoStringBody.js +2 -2
- package/dist/internal/isoYearString.d.ts +21 -0
- package/dist/internal/isoYearString.js +27 -0
- package/dist/internal/joinDateTimeConnector.js +3 -2
- package/dist/internal/leapSeconds.d.ts +63 -0
- package/dist/internal/leapSeconds.js +162 -0
- package/dist/internal/localeWeekInfo.d.ts +1 -1
- package/dist/internal/localeWeekInfo.js +1 -1
- package/dist/internal/maxPieces.js +2 -1
- package/dist/internal/monthGridWeekRow.d.ts +1 -1
- package/dist/internal/normalizeDateTime.d.ts +2 -1
- package/dist/internal/normalizeDateTime.js +3 -2
- package/dist/internal/normalizeTimeZone.d.ts +5 -2
- package/dist/internal/normalizeTimeZone.js +5 -2
- package/dist/internal/offsetTimeline.d.ts +56 -0
- package/dist/internal/offsetTimeline.js +166 -0
- package/dist/internal/operatingSchedule.d.ts +39 -34
- package/dist/internal/operatingSchedule.js +672 -222
- package/dist/internal/patternToken.d.ts +10 -3
- package/dist/internal/patternToken.js +41 -19
- package/dist/internal/plainDateAdd.d.ts +1 -1
- package/dist/internal/plainDateAdd.js +1 -1
- package/dist/internal/plainDateUntil.d.ts +1 -1
- package/dist/internal/plainDateUntil.js +1 -1
- package/dist/internal/readDurationUnits.d.ts +34 -0
- package/dist/internal/readDurationUnits.js +78 -0
- package/dist/internal/readSetFields.d.ts +50 -0
- package/dist/internal/readSetFields.js +179 -0
- package/dist/internal/resolveDurationRelativeTo.d.ts +1 -1
- package/dist/internal/resolveDurationRelativeTo.js +1 -1
- package/dist/internal/resolveLocale.d.ts +2 -2
- package/dist/internal/resolveLocale.js +2 -2
- package/dist/internal/resolveManualRoundingOptions.d.ts +1 -1
- package/dist/internal/resolveRelativeUnit.d.ts +1 -1
- package/dist/internal/resolveRelativeUnit.js +1 -1
- package/dist/internal/resolveUnixIntervalPair.d.ts +9 -3
- package/dist/internal/resolveUnixIntervalPair.js +11 -7
- package/dist/internal/rinexWeek.d.ts +22 -0
- package/dist/internal/rinexWeek.js +30 -0
- package/dist/internal/rollBusinessDate.d.ts +15 -0
- package/dist/internal/rollBusinessDate.js +46 -0
- package/dist/internal/splitStep.d.ts +1 -1
- package/dist/internal/splitStep.js +1 -1
- package/dist/internal/startOrEndOfUnix.d.ts +3 -2
- package/dist/internal/startOrEndOfUnix.js +9 -6
- package/dist/internal/startOrEndOfUtc.d.ts +1 -1
- package/dist/internal/startOrEndOfUtc.js +1 -1
- package/dist/internal/startOrEndOfZoned.d.ts +1 -1
- package/dist/internal/temporal.d.ts +5 -0
- package/dist/internal/temporal.js +5 -0
- package/dist/internal/temporalCompat/calendarDateArithmetic.d.ts +1 -1
- package/dist/internal/temporalCompat/calendarDateFromFields.d.ts +1 -1
- package/dist/internal/temporalCompat/calendarDateFromFields.js +1 -1
- package/dist/internal/temporalCompat/calendarFields.d.ts +1 -1
- package/dist/internal/temporalCompat/capabilities.d.ts +27 -5
- package/dist/internal/temporalCompat/capabilities.js +28 -4
- package/dist/internal/temporalCompat/fieldSearch.d.ts +1 -1
- package/dist/internal/temporalCompat/fieldSearch.js +1 -1
- package/dist/internal/temporalCompat/fixedDay.d.ts +1 -1
- package/dist/internal/temporalCompat/fixedDay.js +1 -1
- package/dist/internal/temporalCompat/index.d.ts +1 -1
- package/dist/internal/temporalCompat/index.js +1 -1
- package/dist/internal/temporalCompat/largeMonthSpan.js +1 -1
- package/dist/internal/temporalCompat/nonIsoArithmetic.d.ts +1 -1
- package/dist/internal/temporalCompat/nonIsoArithmetic.js +1 -1
- package/dist/internal/temporalCompat/probeRepros.d.ts +35 -0
- package/dist/internal/temporalCompat/probeRepros.js +571 -0
- package/dist/internal/temporalCompat/readArithmeticModel.js +2 -2
- package/dist/internal/temporalCompat/repros.d.ts +3 -10
- package/dist/internal/temporalCompat/repros.js +13 -520
- package/dist/internal/timeScaleString.d.ts +47 -0
- package/dist/internal/timeScaleString.js +86 -0
- package/dist/internal/toInstantFromUtc.d.ts +1 -1
- package/dist/internal/toInstantFromUtc.js +1 -1
- package/dist/internal/twoDigitYear.d.ts +19 -0
- package/dist/internal/twoDigitYear.js +22 -0
- package/dist/internal/unixEpochValue.d.ts +1 -1
- package/dist/internal/unixEpochValue.js +4 -3
- package/dist/internal/unixFormatReference.d.ts +1 -1
- package/dist/internal/unixFormatReference.js +1 -1
- package/dist/internal/unixWallClock.d.ts +24 -0
- package/dist/internal/unixWallClock.js +35 -0
- package/dist/internal/utcOffsetString.d.ts +16 -0
- package/dist/internal/utcOffsetString.js +31 -1
- package/dist/internal/utcReading.d.ts +59 -0
- package/dist/internal/utcReading.js +113 -0
- package/dist/internal/utcWallClock.d.ts +20 -0
- package/dist/internal/utcWallClock.js +32 -0
- package/dist/internal/validatedZones.d.ts +20 -0
- package/dist/internal/validatedZones.js +33 -0
- package/dist/internal/wallClockAtOffset.d.ts +1 -1
- package/dist/internal/yearWindowStart.d.ts +28 -0
- package/dist/internal/yearWindowStart.js +52 -0
- package/dist/internal/zoneBucketCap.d.ts +18 -0
- package/dist/internal/zoneBucketCap.js +64 -0
- package/dist/internal/zoneFrame.d.ts +180 -0
- package/dist/internal/zoneFrame.js +221 -0
- package/dist/internal/zonedBucket.d.ts +2 -2
- package/dist/internal/zonedBucket.js +92 -21
- package/dist/internal/zonedFormatReference.d.ts +1 -1
- package/dist/internal/zonedFormatReference.js +1 -1
- package/dist/internal/zonedLocalDates.d.ts +1 -1
- package/dist/internal/zonedLocalDates.js +22 -19
- package/dist/internal/zonedNowUnitValue.d.ts +8 -5
- package/dist/internal/zonedNowUnitValue.js +9 -5
- package/dist/internal/zonedTransitionSearch.d.ts +2 -0
- package/dist/internal/zonedTransitionSearch.js +165 -16
- package/dist/internal/zonedWallClock.d.ts +15 -4
- package/dist/internal/zonedWallClock.js +34 -6
- package/dist/internal/zonedWallClockDifference.d.ts +1 -1
- package/dist/internal/zonedWallClockDifference.js +6 -6
- package/dist/internal/zonedWallClockOperations.d.ts +7 -4
- package/dist/internal/zonedWallClockOperations.js +58 -16
- package/dist/internal/zonelessCalendarDate.d.ts +1 -1
- package/dist/internal/zonelessCalendarDate.js +1 -1
- package/dist/interval/index.d.ts +1 -1
- package/dist/interval/index.js +2 -2
- package/dist/plain/calculate/addBusinessDays.d.ts +2 -2
- package/dist/plain/calculate/addBusinessDays.js +2 -2
- package/dist/plain/calculate/addDate.js +4 -7
- package/dist/plain/calculate/addDateTime.js +5 -8
- package/dist/plain/calculate/addTime.js +5 -8
- package/dist/plain/calculate/clampDate.js +1 -1
- package/dist/plain/calculate/closestDateTo.js +1 -1
- package/dist/plain/calculate/cycleDate.js +1 -1
- package/dist/plain/calculate/cycleDateTime.js +1 -1
- package/dist/plain/calculate/cycleTime.js +1 -1
- package/dist/plain/calculate/diffDate.d.ts +1 -1
- package/dist/plain/calculate/diffDateAsDuration.d.ts +1 -1
- package/dist/plain/calculate/diffDateTime.d.ts +1 -1
- package/dist/plain/calculate/diffDateTime.js +1 -1
- package/dist/plain/calculate/diffDateTimeAsDuration.d.ts +1 -1
- package/dist/plain/calculate/diffDateTimeAsDuration.js +1 -1
- package/dist/plain/calculate/diffTime.d.ts +1 -1
- package/dist/plain/calculate/diffTime.js +1 -1
- package/dist/plain/calculate/endOfDate.d.ts +1 -1
- package/dist/plain/calculate/endOfDate.js +1 -1
- package/dist/plain/calculate/endOfDateTime.d.ts +1 -1
- package/dist/plain/calculate/endOfDateTime.js +1 -1
- package/dist/plain/calculate/endOfQuarterForDate.js +1 -1
- package/dist/plain/calculate/endOfQuarterForDateTime.js +1 -1
- package/dist/plain/calculate/endOfTime.d.ts +2 -2
- package/dist/plain/calculate/endOfTime.js +1 -1
- package/dist/plain/calculate/getDayOfYear.js +1 -1
- package/dist/plain/calculate/getDaysInMonth.js +1 -1
- package/dist/plain/calculate/getDaysInYear.js +1 -1
- package/dist/plain/calculate/getLargestDateDurationUnit.d.ts +1 -1
- package/dist/plain/calculate/getLargestDateTimeDurationUnit.d.ts +1 -1
- package/dist/plain/calculate/getLargestTimeDurationUnit.d.ts +1 -1
- package/dist/plain/calculate/getLocaleDayOfWeek.d.ts +6 -6
- package/dist/plain/calculate/getLocaleDayOfWeek.js +7 -7
- package/dist/plain/calculate/getLocaleEndOfWeek.d.ts +4 -4
- package/dist/plain/calculate/getLocaleEndOfWeek.js +5 -5
- package/dist/plain/calculate/getLocaleStartOfWeek.d.ts +5 -5
- package/dist/plain/calculate/getLocaleStartOfWeek.js +6 -6
- package/dist/plain/calculate/getLocaleWeekYear.d.ts +10 -10
- package/dist/plain/calculate/getLocaleWeekYear.js +11 -11
- package/dist/plain/calculate/getQuarterForDate.js +1 -1
- package/dist/plain/calculate/getQuarterForDateTime.js +1 -1
- package/dist/plain/calculate/getWeekNumber.js +1 -1
- package/dist/plain/calculate/getWeekOfMonth.d.ts +10 -14
- package/dist/plain/calculate/getWeekOfMonth.js +11 -15
- package/dist/plain/calculate/getWeekYear.js +1 -1
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.d.ts +7 -7
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.js +8 -8
- package/dist/plain/calculate/getWeeksInMonth.d.ts +8 -11
- package/dist/plain/calculate/getWeeksInMonth.js +9 -12
- package/dist/plain/calculate/getWeeksInYear.js +1 -1
- package/dist/plain/calculate/maxDate.js +1 -1
- package/dist/plain/calculate/maxDateTime.js +1 -1
- package/dist/plain/calculate/maxTime.js +1 -1
- package/dist/plain/calculate/minDate.js +1 -1
- package/dist/plain/calculate/minDateTime.js +1 -1
- package/dist/plain/calculate/minTime.js +1 -1
- package/dist/plain/calculate/nextWeekday.d.ts +14 -12
- package/dist/plain/calculate/nextWeekday.js +15 -13
- package/dist/plain/calculate/previousWeekday.d.ts +14 -12
- package/dist/plain/calculate/previousWeekday.js +15 -13
- package/dist/plain/calculate/roundDate.d.ts +1 -1
- package/dist/plain/calculate/roundDate.js +1 -1
- package/dist/plain/calculate/roundDateTime.d.ts +1 -1
- package/dist/plain/calculate/roundDateTime.js +1 -1
- package/dist/plain/calculate/roundTime.d.ts +1 -1
- package/dist/plain/calculate/roundTime.js +1 -1
- package/dist/plain/calculate/setDate.d.ts +21 -4
- package/dist/plain/calculate/setDate.js +28 -8
- package/dist/plain/calculate/setDateTime.d.ts +16 -4
- package/dist/plain/calculate/setDateTime.js +23 -8
- package/dist/plain/calculate/setTime.d.ts +14 -2
- package/dist/plain/calculate/setTime.js +22 -7
- package/dist/plain/calculate/sortDateTimes.js +1 -1
- package/dist/plain/calculate/sortDates.js +1 -1
- package/dist/plain/calculate/sortTimes.js +1 -1
- package/dist/plain/calculate/startOfDate.d.ts +1 -1
- package/dist/plain/calculate/startOfDate.js +1 -1
- package/dist/plain/calculate/startOfDateTime.d.ts +1 -1
- package/dist/plain/calculate/startOfDateTime.js +1 -1
- package/dist/plain/calculate/startOfQuarterForDate.js +1 -1
- package/dist/plain/calculate/startOfQuarterForDateTime.js +1 -1
- package/dist/plain/calculate/startOfTime.d.ts +2 -2
- package/dist/plain/calculate/startOfTime.js +1 -1
- package/dist/plain/calculate/subtractBusinessDays.d.ts +2 -2
- package/dist/plain/calculate/subtractBusinessDays.js +2 -2
- package/dist/plain/calculate/subtractDate.js +5 -8
- package/dist/plain/calculate/subtractDateTime.js +5 -8
- package/dist/plain/calculate/subtractTime.js +5 -8
- package/dist/plain/calculate/weekOfYearForDate.js +1 -1
- package/dist/plain/calculate/weekOfYearForDateTime.js +1 -1
- package/dist/plain/chop/chopDate.js +1 -1
- package/dist/plain/chop/chopMilliseconds.js +1 -1
- package/dist/plain/chop/chopSeconds.js +1 -1
- package/dist/plain/chop/chopTime.js +1 -1
- package/dist/plain/compare/areDateTimesEqual.js +1 -1
- package/dist/plain/compare/areDateTimesEqualBy.d.ts +2 -4
- package/dist/plain/compare/areDateTimesEqualBy.js +2 -4
- package/dist/plain/compare/areDatesEqual.js +1 -1
- package/dist/plain/compare/areDatesEqualBy.d.ts +5 -5
- package/dist/plain/compare/areDatesEqualBy.js +5 -5
- package/dist/plain/compare/areTimesEqual.js +1 -1
- package/dist/plain/compare/isAfterDate.js +1 -1
- package/dist/plain/compare/isAfterDateTime.js +1 -1
- package/dist/plain/compare/isAfterTime.js +1 -1
- package/dist/plain/compare/isBeforeDate.js +1 -1
- package/dist/plain/compare/isBeforeDateTime.js +1 -1
- package/dist/plain/compare/isBeforeTime.js +1 -1
- package/dist/plain/compare/isBetweenDate.js +1 -1
- package/dist/plain/compare/isBetweenDateTime.js +1 -1
- package/dist/plain/compare/isBetweenTime.js +1 -1
- package/dist/plain/compare/isBusinessDay.d.ts +2 -2
- package/dist/plain/compare/isBusinessDay.js +3 -3
- package/dist/plain/compare/isRelativeDay.d.ts +1 -1
- package/dist/plain/compare/isRelativeDay.js +1 -1
- package/dist/plain/compare/isThisUnit.d.ts +8 -6
- package/dist/plain/compare/isThisUnit.js +7 -5
- package/dist/plain/compare/isWeekend.d.ts +5 -5
- package/dist/plain/compare/isWeekend.js +6 -6
- package/dist/plain/format/formatCalendar.d.ts +3 -5
- package/dist/plain/format/formatCalendar.js +12 -10
- package/dist/plain/format/formatDate.d.ts +4 -4
- package/dist/plain/format/formatDate.js +8 -7
- package/dist/plain/format/formatDateRange.d.ts +4 -4
- package/dist/plain/format/formatDateRange.js +8 -7
- package/dist/plain/format/formatDateTime.d.ts +4 -4
- package/dist/plain/format/formatDateTime.js +8 -7
- package/dist/plain/format/formatDateTimeRange.d.ts +4 -4
- package/dist/plain/format/formatDateTimeRange.js +8 -7
- package/dist/plain/format/formatDateTimeToParts.d.ts +6 -6
- package/dist/plain/format/formatDateTimeToParts.js +10 -9
- package/dist/plain/format/formatDateToParts.d.ts +6 -6
- package/dist/plain/format/formatDateToParts.js +10 -9
- package/dist/plain/format/formatRelativeDate.d.ts +3 -3
- package/dist/plain/format/formatRelativeDate.js +6 -5
- package/dist/plain/format/formatRelativeDateTime.d.ts +3 -3
- package/dist/plain/format/formatRelativeDateTime.js +6 -5
- package/dist/plain/format/formatRelativeTime.d.ts +3 -3
- package/dist/plain/format/formatRelativeTime.js +6 -5
- package/dist/plain/format/{formatSql.d.ts → formatSqlDateTime.d.ts} +7 -7
- package/dist/plain/format/{formatSql.js → formatSqlDateTime.js} +8 -8
- package/dist/plain/format/formatTime.d.ts +4 -4
- package/dist/plain/format/formatTime.js +8 -7
- package/dist/plain/format/index.d.ts +1 -1
- package/dist/plain/format/index.js +1 -1
- package/dist/plain/get/getDay.js +1 -1
- package/dist/plain/get/getDayOfWeek.js +1 -1
- package/dist/plain/get/getHour.js +1 -1
- package/dist/plain/get/getMicrosecond.js +1 -1
- package/dist/plain/get/getMillisecond.js +1 -1
- package/dist/plain/get/getMinute.js +1 -1
- package/dist/plain/get/getMonth.js +1 -1
- package/dist/plain/get/getNanosecond.js +1 -1
- package/dist/plain/get/getNow.js +1 -1
- package/dist/plain/get/getNowUnit.d.ts +2 -0
- package/dist/plain/get/getNowUnit.js +3 -1
- package/dist/plain/get/getSecond.js +1 -1
- package/dist/plain/get/getToday.js +1 -1
- package/dist/plain/get/getWeekOfYear.js +1 -1
- package/dist/plain/get/getYear.d.ts +2 -0
- package/dist/plain/get/getYear.js +5 -4
- package/dist/plain/index.d.ts +1 -1
- package/dist/plain/index.js +2 -2
- package/dist/plain/interval/intervalAbutsDate.d.ts +1 -2
- package/dist/plain/interval/intervalAbutsDate.js +2 -3
- package/dist/plain/interval/intervalAbutsDateTime.js +1 -1
- package/dist/plain/interval/intervalAbutsTime.js +1 -1
- package/dist/plain/interval/intervalContainsDate.d.ts +1 -1
- package/dist/plain/interval/intervalContainsDate.js +2 -2
- package/dist/plain/interval/intervalContainsDateTime.js +1 -1
- package/dist/plain/interval/intervalContainsTime.js +1 -1
- package/dist/plain/interval/intervalCountDate.js +1 -1
- package/dist/plain/interval/intervalCountDateTime.js +1 -1
- package/dist/plain/interval/intervalCountTime.js +1 -1
- package/dist/plain/interval/intervalDifferenceDate.d.ts +1 -1
- package/dist/plain/interval/intervalDifferenceDate.js +2 -2
- package/dist/plain/interval/intervalDifferenceDateTime.js +1 -1
- package/dist/plain/interval/intervalDifferenceTime.js +1 -1
- package/dist/plain/interval/intervalDivideEquallyDate.d.ts +3 -3
- package/dist/plain/interval/intervalDivideEquallyDate.js +3 -3
- package/dist/plain/interval/intervalDivideEquallyDateTime.js +1 -1
- package/dist/plain/interval/intervalDivideEquallyTime.js +1 -1
- package/dist/plain/interval/intervalEngulfsDate.d.ts +1 -1
- package/dist/plain/interval/intervalEngulfsDate.js +2 -2
- package/dist/plain/interval/intervalEngulfsDateTime.js +1 -1
- package/dist/plain/interval/intervalEngulfsTime.js +1 -1
- package/dist/plain/interval/intervalFromDurationDate.js +1 -1
- package/dist/plain/interval/intervalFromDurationDateTime.js +1 -1
- package/dist/plain/interval/intervalFromDurationTime.js +1 -1
- package/dist/plain/interval/intervalIntersectionDate.d.ts +1 -1
- package/dist/plain/interval/intervalIntersectionDate.js +2 -2
- package/dist/plain/interval/intervalIntersectionDateTime.js +1 -1
- package/dist/plain/interval/intervalIntersectionTime.js +1 -1
- package/dist/plain/interval/intervalLengthDateTime.js +1 -1
- package/dist/plain/interval/intervalLengthTime.js +1 -1
- package/dist/plain/interval/intervalOverlappingDaysDate.js +1 -1
- package/dist/plain/interval/intervalOverlappingDaysDateTime.js +1 -1
- package/dist/plain/interval/intervalSplitAtDate.d.ts +1 -1
- package/dist/plain/interval/intervalSplitAtDate.js +2 -2
- package/dist/plain/interval/intervalSplitAtDateTime.js +1 -1
- package/dist/plain/interval/intervalSplitAtTime.js +1 -1
- package/dist/plain/interval/intervalUnionDate.d.ts +2 -2
- package/dist/plain/interval/intervalUnionDate.js +3 -3
- package/dist/plain/interval/intervalUnionDateTime.js +1 -1
- package/dist/plain/interval/intervalUnionTime.js +1 -1
- package/dist/plain/interval/intervalXorAllDate.d.ts +1 -1
- package/dist/plain/interval/intervalXorAllDate.js +4 -4
- package/dist/plain/interval/intervalXorAllDateTime.js +3 -3
- package/dist/plain/interval/intervalXorAllTime.js +3 -3
- package/dist/plain/interval/intervalXorDate.d.ts +1 -1
- package/dist/plain/interval/intervalXorDate.js +2 -2
- package/dist/plain/interval/intervalXorDateTime.js +1 -1
- package/dist/plain/interval/intervalXorTime.js +1 -1
- package/dist/plain/interval/intervalsOverlapDate.d.ts +1 -1
- package/dist/plain/interval/intervalsOverlapDate.js +2 -2
- package/dist/plain/interval/intervalsOverlapDateTime.js +1 -1
- package/dist/plain/interval/intervalsOverlapTime.js +1 -1
- package/dist/plain/interval/mergeIntervalsDate.d.ts +1 -1
- package/dist/plain/interval/mergeIntervalsDate.js +4 -4
- package/dist/plain/interval/mergeIntervalsDateTime.js +3 -3
- package/dist/plain/interval/mergeIntervalsTime.js +3 -3
- package/dist/plain/interval/splitIntervalByUnitDate.d.ts +2 -3
- package/dist/plain/interval/splitIntervalByUnitDate.js +3 -4
- package/dist/plain/interval/splitIntervalByUnitDateTime.d.ts +2 -1
- package/dist/plain/interval/splitIntervalByUnitDateTime.js +3 -2
- package/dist/plain/interval/splitIntervalByUnitTime.js +1 -1
- package/dist/plain/interval/validate/isValidDateInterval.d.ts +1 -1
- package/dist/plain/interval/validate/isValidDateInterval.js +2 -2
- package/dist/plain/interval/validate/isValidDateTimeInterval.js +1 -1
- package/dist/plain/interval/validate/isValidTimeInterval.js +1 -1
- package/dist/plain/locale/getLocaleEraNames.d.ts +6 -6
- package/dist/plain/locale/getLocaleEraNames.js +8 -7
- package/dist/plain/locale/getLocaleMeridiems.d.ts +5 -5
- package/dist/plain/locale/getLocaleMeridiems.js +7 -6
- package/dist/plain/locale/getLocaleMonthNames.d.ts +6 -6
- package/dist/plain/locale/getLocaleMonthNames.js +17 -11
- package/dist/plain/locale/getLocaleWeekdayNames.d.ts +3 -3
- package/dist/plain/locale/getLocaleWeekdayNames.js +12 -5
- package/dist/plain/map/mapDatesInRange.js +1 -1
- package/dist/plain/map/mapDaysInMonth.js +1 -1
- package/dist/plain/parse/index.d.ts +1 -1
- package/dist/plain/parse/index.js +1 -1
- package/dist/plain/parse/parseDateTimeWithPattern.d.ts +28 -14
- package/dist/plain/parse/parseDateTimeWithPattern.js +33 -17
- package/dist/plain/parse/parseDateWithPattern.d.ts +29 -14
- package/dist/plain/parse/parseDateWithPattern.js +34 -17
- package/dist/plain/parse/parseDayFromDate.js +1 -1
- package/dist/plain/parse/parseDayFromDateTime.js +1 -1
- package/dist/plain/parse/parseDayOfWeekFromDate.js +1 -1
- package/dist/plain/parse/parseDayOfWeekFromDateTime.js +1 -1
- package/dist/plain/parse/parseHourFromDateTime.js +1 -1
- package/dist/plain/parse/parseHourFromTime.js +1 -1
- package/dist/plain/parse/parseMicrosecondFromDateTime.js +1 -1
- package/dist/plain/parse/parseMicrosecondFromTime.js +1 -1
- package/dist/plain/parse/parseMillisecondFromDateTime.js +1 -1
- package/dist/plain/parse/parseMillisecondFromTime.js +1 -1
- package/dist/plain/parse/parseMinuteFromDateTime.js +1 -1
- package/dist/plain/parse/parseMinuteFromTime.js +1 -1
- package/dist/plain/parse/parseMonthFromDate.js +1 -1
- package/dist/plain/parse/parseMonthFromDateTime.js +1 -1
- package/dist/plain/parse/parseNanosecondFromDateTime.js +1 -1
- package/dist/plain/parse/parseNanosecondFromTime.js +1 -1
- package/dist/plain/parse/parseSecondFromDateTime.js +1 -1
- package/dist/plain/parse/parseSecondFromTime.js +1 -1
- package/dist/plain/parse/{parseSql.d.ts → parseSqlDateTime.d.ts} +8 -8
- package/dist/plain/parse/{parseSql.js → parseSqlDateTime.js} +9 -9
- package/dist/plain/parse/parseTimeWithPattern.d.ts +6 -4
- package/dist/plain/parse/parseTimeWithPattern.js +8 -5
- package/dist/plain/parse/parseUnitFromDate.d.ts +4 -1
- package/dist/plain/parse/parseUnitFromDate.js +6 -2
- package/dist/plain/parse/parseUnitFromDateTime.d.ts +4 -1
- package/dist/plain/parse/parseUnitFromDateTime.js +6 -2
- package/dist/plain/parse/parseUnitFromTime.d.ts +1 -1
- package/dist/plain/parse/parseUnitFromTime.js +1 -1
- package/dist/plain/parse/parseWeekFromDateTime.js +1 -1
- package/dist/plain/parse/parseYearFromDate.d.ts +5 -2
- package/dist/plain/parse/parseYearFromDate.js +8 -4
- package/dist/plain/parse/parseYearFromDateTime.d.ts +4 -2
- package/dist/plain/parse/parseYearFromDateTime.js +7 -4
- package/dist/plain/validate/{isLeapSecond.d.ts → hasSecond60.d.ts} +16 -14
- package/dist/plain/validate/{isLeapSecond.js → hasSecond60.js} +16 -14
- package/dist/plain/validate/index.d.ts +2 -1
- package/dist/plain/validate/index.js +2 -1
- package/dist/plain/validate/isLeapYear.js +1 -1
- package/dist/plain/validate/isValidDate.js +2 -17
- package/dist/plain/validate/isValidDateRange.js +1 -1
- package/dist/plain/validate/isValidDateTime.d.ts +1 -1
- package/dist/plain/validate/isValidDateTime.js +4 -4
- package/dist/plain/validate/isValidDateTimeRange.js +1 -1
- package/dist/plain/validate/isValidIsoDateLike.js +3 -3
- package/dist/plain/validate/isValidSqlDateTime.d.ts +33 -0
- package/dist/plain/validate/isValidSqlDateTime.js +36 -0
- package/dist/plain/validate/isValidTime.js +2 -18
- package/dist/plain/validate/isValidTimeRange.js +1 -1
- package/dist/precision/convert/fromNanoseconds.d.ts +11 -5
- package/dist/precision/convert/fromNanoseconds.js +12 -6
- package/dist/precision/convert/toNanoseconds.d.ts +2 -2
- package/dist/precision/convert/toNanoseconds.js +2 -2
- package/dist/precision/index.d.ts +1 -1
- package/dist/precision/index.js +2 -2
- package/dist/precision/validate/isValidInstant.d.ts +1 -1
- package/dist/precision/validate/isValidInstant.js +1 -1
- package/dist/regex/calendar-zoned-date-time.d.ts +4 -4
- package/dist/regex/calendar-zoned-date-time.js +4 -4
- package/dist/regex/epcis.d.ts +60 -0
- package/dist/regex/epcis.js +60 -0
- package/dist/regex/http-date.d.ts +6 -4
- package/dist/regex/http-date.js +6 -4
- package/dist/regex/index.d.ts +2 -1
- package/dist/regex/index.js +3 -2
- package/dist/regex/leap-second.d.ts +1 -1
- package/dist/regex/leap-second.js +1 -1
- package/dist/regex/rfc-2822.d.ts +2 -0
- package/dist/regex/rfc-2822.js +2 -0
- package/dist/regex/rfc-3339.d.ts +3 -1
- package/dist/regex/rfc-3339.js +3 -1
- package/dist/regex/sql-date-time.d.ts +2 -1
- package/dist/regex/sql-date-time.js +2 -1
- package/dist/regex/time-zone-like.d.ts +5 -4
- package/dist/regex/time-zone-like.js +5 -4
- package/dist/regex/utc-offset.d.ts +2 -1
- package/dist/regex/utc-offset.js +2 -1
- package/dist/span/calculate/spanMs.d.ts +4 -3
- package/dist/span/calculate/spanMs.js +4 -3
- package/dist/span/calculate/spanNs.d.ts +4 -3
- package/dist/span/calculate/spanNs.js +4 -3
- package/dist/span/calculate/spanWallClock.d.ts +12 -12
- package/dist/span/calculate/spanWallClock.js +13 -13
- package/dist/span/index.d.ts +1 -1
- package/dist/span/index.js +2 -2
- package/dist/span/validate/isValidSpan.d.ts +3 -3
- package/dist/span/validate/isValidSpan.js +3 -3
- package/dist/timescale/calculate/index.d.ts +3 -0
- package/dist/timescale/calculate/index.js +3 -0
- package/dist/timescale/calculate/leapSecondsBetween.d.ts +26 -0
- package/dist/timescale/calculate/leapSecondsBetween.js +62 -0
- package/dist/timescale/calculate/nextLeapSecond.d.ts +18 -0
- package/dist/timescale/calculate/nextLeapSecond.js +33 -0
- package/dist/timescale/calculate/taiMinusUtc.d.ts +21 -0
- package/dist/timescale/calculate/taiMinusUtc.js +38 -0
- package/dist/timescale/convert/fromTAI.d.ts +22 -0
- package/dist/timescale/convert/fromTAI.js +35 -0
- package/dist/timescale/convert/index.d.ts +2 -0
- package/dist/timescale/convert/index.js +2 -0
- package/dist/timescale/convert/toTAI.d.ts +23 -0
- package/dist/timescale/convert/toTAI.js +39 -0
- package/dist/timescale/index.d.ts +4 -0
- package/dist/timescale/index.js +5 -0
- package/dist/timescale/validate/index.d.ts +1 -0
- package/dist/timescale/validate/index.js +1 -0
- package/dist/timescale/validate/isLeapSecond.d.ts +25 -0
- package/dist/timescale/validate/isLeapSecond.js +36 -0
- package/dist/transport/calculate/crossingTime.d.ts +8 -3
- package/dist/transport/calculate/crossingTime.js +9 -4
- package/dist/transport/calculate/cutoffAt.d.ts +10 -5
- package/dist/transport/calculate/cutoffAt.js +26 -133
- package/dist/transport/calculate/cutoffSchedule.d.ts +8 -3
- package/dist/transport/calculate/cutoffSchedule.js +54 -20
- package/dist/transport/calculate/dwellTime.d.ts +9 -4
- package/dist/transport/calculate/dwellTime.js +10 -5
- package/dist/transport/calculate/estimateDrift.d.ts +1 -1
- package/dist/transport/calculate/estimateDrift.js +1 -1
- package/dist/transport/calculate/nextDeparture.d.ts +2 -2
- package/dist/transport/calculate/nextDeparture.js +2 -2
- package/dist/transport/calculate/scheduleDelivery.d.ts +15 -7
- package/dist/transport/calculate/scheduleDelivery.js +9 -4
- package/dist/transport/calculate/transitTime.d.ts +11 -11
- package/dist/transport/calculate/transitTime.js +11 -11
- package/dist/transport/compare/classifyPunctuality.d.ts +1 -1
- package/dist/transport/compare/classifyPunctuality.js +1 -1
- package/dist/transport/compare/isPastCutoff.d.ts +1 -1
- package/dist/transport/compare/isPastCutoff.js +2 -2
- package/dist/transport/compare/scheduleDeviation.d.ts +1 -1
- package/dist/transport/compare/scheduleDeviation.js +1 -1
- package/dist/transport/compare/timeToCutoff.d.ts +1 -1
- package/dist/transport/compare/timeToCutoff.js +1 -1
- package/dist/transport/convert/etaAtZone.d.ts +8 -3
- package/dist/transport/convert/etaAtZone.js +8 -3
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +2 -2
- package/dist/types/business-calendar.d.ts +5 -4
- package/dist/types/date-duration-unit.d.ts +1 -1
- package/dist/types/date-time-duration-units.d.ts +1 -1
- package/dist/types/date-time-unit.d.ts +1 -1
- package/dist/types/date-unit.d.ts +1 -1
- package/dist/types/disambiguation.d.ts +1 -1
- package/dist/types/duration-relative-to.d.ts +1 -1
- package/dist/types/duration-string-options.d.ts +1 -1
- package/dist/types/duty.d.ts +777 -0
- package/dist/types/duty.js +0 -0
- package/dist/types/edi.d.ts +407 -0
- package/dist/types/edi.js +0 -0
- package/dist/types/epcis.d.ts +25 -0
- package/dist/types/epcis.js +0 -0
- package/dist/types/exact-duration-unit.d.ts +8 -0
- package/dist/types/exact-duration-unit.js +0 -0
- package/dist/types/fiscal-calendar.d.ts +40 -4
- package/dist/types/free-time-options.d.ts +4 -3
- package/dist/types/gnss.d.ts +51 -0
- package/dist/types/gnss.js +0 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +7 -0
- package/dist/types/now-unit.d.ts +1 -1
- package/dist/types/offset.d.ts +1 -1
- package/dist/types/operating-schedule.d.ts +3 -2
- package/dist/types/overflow.d.ts +1 -1
- package/dist/types/rounding-options.d.ts +1 -1
- package/dist/types/stored-zoned-classification.d.ts +83 -0
- package/dist/types/stored-zoned-classification.js +0 -0
- package/dist/types/time-duration-unit.d.ts +1 -1
- package/dist/types/time-unit.d.ts +1 -1
- package/dist/types/two-digit-year.d.ts +23 -0
- package/dist/types/two-digit-year.js +0 -0
- package/dist/types/utc-now-unit.d.ts +1 -1
- package/dist/types/zone-bucket-unit.d.ts +1 -1
- package/dist/unix/calculate/addUnix.d.ts +11 -2
- package/dist/unix/calculate/addUnix.js +14 -11
- package/dist/unix/calculate/diffUnix.d.ts +11 -3
- package/dist/unix/calculate/diffUnix.js +11 -6
- package/dist/unix/calculate/diffUnixAsDuration.d.ts +11 -3
- package/dist/unix/calculate/diffUnixAsDuration.js +10 -5
- package/dist/unix/calculate/endOfQuarterForUnix.d.ts +10 -2
- package/dist/unix/calculate/endOfQuarterForUnix.js +6 -0
- package/dist/unix/calculate/endOfUnix.d.ts +13 -4
- package/dist/unix/calculate/endOfUnix.js +8 -1
- package/dist/unix/calculate/isBetweenUnix.d.ts +3 -2
- package/dist/unix/calculate/isBetweenUnix.js +4 -4
- package/dist/unix/calculate/roundUnix.d.ts +17 -7
- package/dist/unix/calculate/roundUnix.js +19 -10
- package/dist/unix/calculate/setUnix.d.ts +28 -8
- package/dist/unix/calculate/setUnix.js +35 -14
- package/dist/unix/calculate/startOfQuarterForUnix.d.ts +10 -2
- package/dist/unix/calculate/startOfQuarterForUnix.js +6 -0
- package/dist/unix/calculate/startOfUnix.d.ts +13 -4
- package/dist/unix/calculate/startOfUnix.js +8 -1
- package/dist/unix/calculate/subtractUnix.d.ts +10 -2
- package/dist/unix/calculate/subtractUnix.js +13 -11
- package/dist/unix/compare/areUnixEqualBy.d.ts +13 -4
- package/dist/unix/compare/areUnixEqualBy.js +8 -1
- package/dist/unix/convert/convertUnixToPlainDate.d.ts +5 -2
- package/dist/unix/convert/convertUnixToPlainDate.js +5 -4
- package/dist/unix/convert/convertUnixToPlainDateTime.d.ts +5 -2
- package/dist/unix/convert/convertUnixToPlainDateTime.js +5 -4
- package/dist/unix/convert/convertUnixToPlainTime.d.ts +6 -3
- package/dist/unix/convert/convertUnixToPlainTime.js +6 -5
- package/dist/unix/convert/convertUnixToZoned.d.ts +6 -2
- package/dist/unix/convert/convertUnixToZoned.js +6 -2
- package/dist/unix/format/formatCalendarUnix.d.ts +16 -11
- package/dist/unix/format/formatCalendarUnix.js +12 -7
- package/dist/unix/format/formatRelativeUnix.d.ts +17 -9
- package/dist/unix/format/formatRelativeUnix.js +19 -11
- package/dist/unix/format/formatUnix.d.ts +16 -11
- package/dist/unix/format/formatUnix.js +13 -9
- package/dist/unix/get/getUnixDay.d.ts +1 -3
- package/dist/unix/get/getUnixDay.js +6 -13
- package/dist/unix/get/getUnixHour.d.ts +1 -3
- package/dist/unix/get/getUnixHour.js +6 -13
- package/dist/unix/get/getUnixMicrosecond.d.ts +1 -3
- package/dist/unix/get/getUnixMicrosecond.js +5 -12
- package/dist/unix/get/getUnixMillisecond.d.ts +1 -3
- package/dist/unix/get/getUnixMillisecond.js +6 -13
- package/dist/unix/get/getUnixMinute.d.ts +1 -3
- package/dist/unix/get/getUnixMinute.js +6 -13
- package/dist/unix/get/getUnixMonth.d.ts +1 -3
- package/dist/unix/get/getUnixMonth.js +6 -13
- package/dist/unix/get/getUnixNanosecond.d.ts +1 -3
- package/dist/unix/get/getUnixNanosecond.js +5 -12
- package/dist/unix/get/getUnixNow.js +1 -1
- package/dist/unix/get/getUnixNowUnit.d.ts +3 -1
- package/dist/unix/get/getUnixNowUnit.js +3 -1
- package/dist/unix/get/getUnixSecond.d.ts +1 -3
- package/dist/unix/get/getUnixSecond.js +6 -13
- package/dist/unix/get/getUnixYear.d.ts +3 -3
- package/dist/unix/get/getUnixYear.js +6 -13
- package/dist/unix/index.d.ts +1 -1
- package/dist/unix/index.js +2 -2
- package/dist/unix/interval/intervalCountUnix.d.ts +11 -2
- package/dist/unix/interval/intervalCountUnix.js +7 -0
- package/dist/unix/interval/intervalFromDurationUnix.d.ts +10 -2
- package/dist/unix/interval/intervalFromDurationUnix.js +13 -8
- package/dist/unix/interval/intervalLengthUnix.d.ts +12 -4
- package/dist/unix/interval/intervalLengthUnix.js +8 -2
- package/dist/unix/interval/intervalOverlappingDaysUnix.d.ts +10 -2
- package/dist/unix/interval/intervalOverlappingDaysUnix.js +10 -5
- package/dist/unix/interval/splitIntervalByUnitUnix.d.ts +13 -4
- package/dist/unix/interval/splitIntervalByUnitUnix.js +16 -9
- package/dist/unix/parse/parseDateFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseDateFromUnix.js +3 -3
- package/dist/unix/parse/parseDayFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseDayOfWeekFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseDayOfWeekFromUnix.js +2 -2
- package/dist/unix/parse/parseHourFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMicrosecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMillisecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMinuteFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseMonthFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseNanosecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseSecondFromUnix.d.ts +4 -2
- package/dist/unix/parse/parseTimeFromUnix.d.ts +5 -2
- package/dist/unix/parse/parseTimeFromUnix.js +4 -3
- package/dist/unix/parse/parseUnitFromUnix.d.ts +10 -4
- package/dist/unix/parse/parseUnitFromUnix.js +21 -14
- package/dist/unix/parse/parseWeekFromUnix.d.ts +3 -2
- package/dist/unix/parse/parseWeekFromUnix.js +4 -4
- package/dist/unix/parse/parseYearFromUnix.d.ts +8 -3
- package/dist/unix/parse/parseYearFromUnix.js +4 -1
- package/dist/unix/validate/isValidUnixUnit.d.ts +1 -1
- package/dist/utc/calculate/addUtc.js +5 -8
- package/dist/utc/calculate/diffUtc.d.ts +1 -1
- package/dist/utc/calculate/diffUtc.js +1 -1
- package/dist/utc/calculate/diffUtcAsDuration.d.ts +1 -1
- package/dist/utc/calculate/diffUtcAsDuration.js +1 -1
- package/dist/utc/calculate/endOfQuarterForUtc.js +1 -1
- package/dist/utc/calculate/endOfUtc.d.ts +1 -1
- package/dist/utc/calculate/isBetweenUtc.js +1 -1
- package/dist/utc/calculate/maxUtc.js +1 -1
- package/dist/utc/calculate/minUtc.js +1 -1
- package/dist/utc/calculate/roundUtc.d.ts +1 -1
- package/dist/utc/calculate/roundUtc.js +1 -1
- package/dist/utc/calculate/setUtc.d.ts +17 -4
- package/dist/utc/calculate/setUtc.js +23 -9
- package/dist/utc/calculate/sortUtc.js +1 -1
- package/dist/utc/calculate/startOfQuarterForUtc.js +1 -1
- package/dist/utc/calculate/startOfUtc.d.ts +1 -1
- package/dist/utc/calculate/subtractUtc.js +5 -8
- package/dist/utc/compare/areUtcEqual.js +1 -1
- package/dist/utc/compare/areUtcEqualBy.d.ts +2 -2
- package/dist/utc/compare/areUtcEqualBy.js +2 -2
- package/dist/utc/compare/isAfterUtc.js +1 -1
- package/dist/utc/compare/isBeforeUtc.js +1 -1
- package/dist/utc/convert/convertUtcToPlainDate.d.ts +9 -3
- package/dist/utc/convert/convertUtcToPlainDate.js +12 -9
- package/dist/utc/convert/convertUtcToPlainDateTime.d.ts +10 -3
- package/dist/utc/convert/convertUtcToPlainDateTime.js +14 -15
- package/dist/utc/convert/convertUtcToPlainTime.d.ts +6 -3
- package/dist/utc/convert/convertUtcToPlainTime.js +9 -8
- package/dist/utc/convert/convertUtcToUnix.js +1 -1
- package/dist/utc/convert/convertUtcToZoned.d.ts +6 -2
- package/dist/utc/convert/convertUtcToZoned.js +7 -3
- package/dist/utc/format/formatCalendarUtc.d.ts +12 -7
- package/dist/utc/format/formatCalendarUtc.js +9 -4
- package/dist/utc/format/{formatHttp.d.ts → formatHttpDate.d.ts} +7 -7
- package/dist/utc/format/{formatHttp.js → formatHttpDate.js} +8 -8
- package/dist/utc/format/formatRelativeUtc.d.ts +15 -7
- package/dist/utc/format/formatRelativeUtc.js +17 -9
- package/dist/utc/format/formatUtc.d.ts +15 -10
- package/dist/utc/format/formatUtc.js +12 -8
- package/dist/utc/format/index.d.ts +1 -1
- package/dist/utc/format/index.js +1 -1
- package/dist/utc/get/getUtcDay.d.ts +1 -3
- package/dist/utc/get/getUtcDay.js +6 -13
- package/dist/utc/get/getUtcHour.d.ts +1 -3
- package/dist/utc/get/getUtcHour.js +6 -13
- package/dist/utc/get/getUtcMicrosecond.d.ts +1 -3
- package/dist/utc/get/getUtcMicrosecond.js +5 -12
- package/dist/utc/get/getUtcMillisecond.d.ts +1 -3
- package/dist/utc/get/getUtcMillisecond.js +6 -13
- package/dist/utc/get/getUtcMinute.d.ts +1 -3
- package/dist/utc/get/getUtcMinute.js +6 -13
- package/dist/utc/get/getUtcMonth.d.ts +1 -3
- package/dist/utc/get/getUtcMonth.js +6 -13
- package/dist/utc/get/getUtcNanosecond.d.ts +1 -3
- package/dist/utc/get/getUtcNanosecond.js +5 -12
- package/dist/utc/get/getUtcNow.d.ts +1 -3
- package/dist/utc/get/getUtcNow.js +3 -10
- package/dist/utc/get/getUtcNowUnit.d.ts +2 -0
- package/dist/utc/get/getUtcNowUnit.js +3 -1
- package/dist/utc/get/getUtcSecond.d.ts +1 -3
- package/dist/utc/get/getUtcSecond.js +6 -13
- package/dist/utc/get/getUtcYear.d.ts +3 -3
- package/dist/utc/get/getUtcYear.js +6 -13
- package/dist/utc/index.d.ts +1 -1
- package/dist/utc/index.js +2 -2
- package/dist/utc/interval/intervalAbutsUtc.js +1 -1
- package/dist/utc/interval/intervalContainsUtc.js +1 -1
- package/dist/utc/interval/intervalCountUtc.js +1 -1
- package/dist/utc/interval/intervalDivideEquallyUtc.js +1 -1
- package/dist/utc/interval/intervalEngulfsUtc.js +1 -1
- package/dist/utc/interval/intervalFromDurationUtc.js +1 -1
- package/dist/utc/interval/intervalLengthUtc.js +1 -1
- package/dist/utc/interval/intervalOverlappingDaysUtc.js +1 -1
- package/dist/utc/interval/intervalSplitAtUtc.js +1 -1
- package/dist/utc/interval/intervalXorAllUtc.js +3 -3
- package/dist/utc/interval/intervalXorUtc.js +1 -1
- package/dist/utc/interval/mergeIntervalsUtc.js +2 -2
- package/dist/utc/interval/splitIntervalByUnitUtc.d.ts +2 -1
- package/dist/utc/interval/splitIntervalByUnitUtc.js +3 -2
- package/dist/utc/interval/validate/isValidUtcInterval.js +1 -1
- package/dist/utc/parse/index.d.ts +1 -1
- package/dist/utc/parse/index.js +1 -1
- package/dist/utc/parse/parseDateFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseDateFromUtc.js +3 -3
- package/dist/utc/parse/parseDayFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseDayFromUtc.js +3 -3
- package/dist/utc/parse/parseDayOfWeekFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseDayOfWeekFromUtc.js +6 -6
- package/dist/utc/parse/parseHourFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseHourFromUtc.js +3 -3
- package/dist/utc/parse/{parseHttp.d.ts → parseHttpDate.d.ts} +12 -12
- package/dist/utc/parse/{parseHttp.js → parseHttpDate.js} +13 -13
- package/dist/utc/parse/parseMicrosecondFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseMicrosecondFromUtc.js +3 -3
- package/dist/utc/parse/parseMillisecondFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseMillisecondFromUtc.js +3 -3
- package/dist/utc/parse/parseMinuteFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMinuteFromUtc.js +2 -2
- package/dist/utc/parse/parseMonthFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseMonthFromUtc.js +3 -3
- package/dist/utc/parse/parseNanosecondFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseNanosecondFromUtc.js +3 -3
- package/dist/utc/parse/parseSecondFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseSecondFromUtc.js +3 -3
- package/dist/utc/parse/parseTimeFromUtc.d.ts +6 -3
- package/dist/utc/parse/parseTimeFromUtc.js +7 -6
- package/dist/utc/parse/parseUnitFromUtc.d.ts +12 -5
- package/dist/utc/parse/parseUnitFromUtc.js +13 -7
- package/dist/utc/parse/parseWeekFromUtc.d.ts +5 -3
- package/dist/utc/parse/parseWeekFromUtc.js +6 -6
- package/dist/utc/parse/parseYearFromUtc.d.ts +9 -5
- package/dist/utc/parse/parseYearFromUtc.js +9 -6
- package/dist/utc/validate/index.d.ts +2 -0
- package/dist/utc/validate/index.js +2 -0
- package/dist/utc/validate/isValidHttpDate.d.ts +35 -0
- package/dist/utc/validate/isValidHttpDate.js +38 -0
- package/dist/utc/validate/isValidUtc.d.ts +4 -0
- package/dist/utc/validate/isValidUtc.js +7 -3
- package/dist/utc/validate/isValidUtcRange.js +1 -1
- package/dist/utc/validate/isValidUtcTimestamp.d.ts +43 -0
- package/dist/utc/validate/isValidUtcTimestamp.js +48 -0
- package/dist/workforce/calculate/dutyDayFor.d.ts +38 -0
- package/dist/workforce/calculate/dutyDayFor.js +71 -0
- package/dist/workforce/calculate/dutyTotals.d.ts +24 -0
- package/dist/workforce/calculate/dutyTotals.js +41 -0
- package/dist/workforce/calculate/dutyViolations.d.ts +74 -0
- package/dist/workforce/calculate/dutyViolations.js +65 -0
- package/dist/workforce/calculate/evaluateDutyLog.d.ts +77 -0
- package/dist/workforce/calculate/evaluateDutyLog.js +75 -0
- package/dist/workforce/calculate/index.d.ts +7 -0
- package/dist/workforce/calculate/index.js +7 -0
- package/dist/workforce/calculate/longestRun.d.ts +28 -0
- package/dist/workforce/calculate/longestRun.js +54 -0
- package/dist/workforce/calculate/qualifyingRestPairs.d.ts +37 -0
- package/dist/workforce/calculate/qualifyingRestPairs.js +58 -0
- package/dist/workforce/calculate/qualifyingRests.d.ts +27 -0
- package/dist/workforce/calculate/qualifyingRests.js +49 -0
- package/dist/workforce/index.d.ts +3 -0
- package/dist/workforce/index.js +4 -0
- package/dist/workforce/validate/index.d.ts +1 -0
- package/dist/workforce/validate/index.js +1 -0
- package/dist/workforce/validate/isValidDutyLog.d.ts +24 -0
- package/dist/workforce/validate/isValidDutyLog.js +34 -0
- package/dist/zoned/calculate/addZoned.d.ts +15 -15
- package/dist/zoned/calculate/addZoned.js +19 -22
- package/dist/zoned/calculate/addZonedBusinessDays.d.ts +5 -4
- package/dist/zoned/calculate/addZonedBusinessDays.js +5 -4
- package/dist/zoned/calculate/clampZoned.js +1 -1
- package/dist/zoned/calculate/diffZoned.d.ts +8 -8
- package/dist/zoned/calculate/diffZoned.js +7 -7
- package/dist/zoned/calculate/diffZonedAsDuration.d.ts +5 -5
- package/dist/zoned/calculate/diffZonedAsDuration.js +4 -4
- package/dist/zoned/calculate/endOfZoned.d.ts +3 -3
- package/dist/zoned/calculate/endOfZoned.js +2 -2
- package/dist/zoned/calculate/getHoursInZonedDay.d.ts +2 -2
- package/dist/zoned/calculate/getHoursInZonedDay.js +2 -2
- package/dist/zoned/calculate/getLocaleZonedDayOfWeek.d.ts +6 -5
- package/dist/zoned/calculate/getLocaleZonedDayOfWeek.js +6 -5
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.d.ts +5 -5
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.js +5 -5
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.d.ts +6 -6
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.js +6 -6
- package/dist/zoned/calculate/maxZoned.d.ts +2 -2
- package/dist/zoned/calculate/maxZoned.js +3 -3
- package/dist/zoned/calculate/minZoned.d.ts +2 -2
- package/dist/zoned/calculate/minZoned.js +3 -3
- package/dist/zoned/calculate/roundZoned.d.ts +11 -9
- package/dist/zoned/calculate/roundZoned.js +11 -9
- package/dist/zoned/calculate/setZoned.d.ts +26 -12
- package/dist/zoned/calculate/setZoned.js +33 -16
- package/dist/zoned/calculate/sortZoned.d.ts +3 -3
- package/dist/zoned/calculate/sortZoned.js +4 -4
- package/dist/zoned/calculate/startOfZoned.d.ts +3 -3
- package/dist/zoned/calculate/startOfZoned.js +2 -2
- package/dist/zoned/calculate/subtractZoned.d.ts +14 -14
- package/dist/zoned/calculate/subtractZoned.js +18 -21
- package/dist/zoned/calculate/subtractZonedBusinessDays.d.ts +5 -4
- package/dist/zoned/calculate/subtractZonedBusinessDays.js +5 -4
- package/dist/zoned/chop/chopZonedDate.d.ts +1 -1
- package/dist/zoned/chop/chopZonedDate.js +1 -1
- package/dist/zoned/chop/chopZonedMilliseconds.d.ts +1 -1
- package/dist/zoned/chop/chopZonedMilliseconds.js +1 -1
- package/dist/zoned/chop/chopZonedSeconds.d.ts +1 -1
- package/dist/zoned/chop/chopZonedSeconds.js +1 -1
- package/dist/zoned/chop/chopZonedTime.d.ts +1 -1
- package/dist/zoned/chop/chopZonedTime.js +1 -1
- package/dist/zoned/chop/chopZonedTimezone.d.ts +1 -1
- package/dist/zoned/chop/chopZonedTimezone.js +1 -1
- package/dist/zoned/classify/classifyStoredZoned.d.ts +46 -0
- package/dist/zoned/classify/classifyStoredZoned.js +177 -0
- package/dist/zoned/classify/index.d.ts +1 -0
- package/dist/zoned/classify/index.js +1 -0
- package/dist/zoned/compare/areZonedEqual.js +1 -1
- package/dist/zoned/compare/areZonedEqualBy.d.ts +8 -10
- package/dist/zoned/compare/areZonedEqualBy.js +8 -10
- package/dist/zoned/compare/isAfterZoned.js +1 -1
- package/dist/zoned/compare/isBeforeZoned.d.ts +2 -2
- package/dist/zoned/compare/isBeforeZoned.js +3 -3
- package/dist/zoned/compare/isBetweenZoned.js +1 -1
- package/dist/zoned/compare/isInDaylightSaving.d.ts +2 -2
- package/dist/zoned/compare/isInDaylightSaving.js +2 -2
- package/dist/zoned/compare/isZonedBusinessDay.d.ts +7 -6
- package/dist/zoned/compare/isZonedBusinessDay.js +7 -6
- package/dist/zoned/compare/isZonedFuture.js +1 -1
- package/dist/zoned/compare/isZonedPast.js +1 -1
- package/dist/zoned/compare/isZonedRelativeDay.d.ts +2 -2
- package/dist/zoned/compare/isZonedRelativeDay.js +3 -3
- package/dist/zoned/compare/isZonedThisUnit.d.ts +7 -7
- package/dist/zoned/compare/isZonedThisUnit.js +7 -7
- package/dist/zoned/compare/isZonedWeekend.d.ts +5 -5
- package/dist/zoned/compare/isZonedWeekend.js +5 -5
- package/dist/zoned/convert/convertPlainDateTimeToZoned.d.ts +10 -7
- package/dist/zoned/convert/convertPlainDateTimeToZoned.js +10 -7
- package/dist/zoned/convert/convertZonedToCalendar.d.ts +5 -5
- package/dist/zoned/convert/convertZonedToCalendar.js +5 -5
- package/dist/zoned/convert/convertZonedToPlainDateTime.d.ts +3 -3
- package/dist/zoned/convert/convertZonedToPlainDateTime.js +3 -3
- package/dist/zoned/convert/convertZonedToZoned.d.ts +7 -3
- package/dist/zoned/convert/convertZonedToZoned.js +7 -3
- package/dist/zoned/format/formatCalendarZoned.d.ts +7 -6
- package/dist/zoned/format/formatCalendarZoned.js +7 -6
- package/dist/zoned/format/formatRelativeZoned.d.ts +3 -3
- package/dist/zoned/format/formatRelativeZoned.js +6 -5
- package/dist/zoned/format/formatRfc2822.d.ts +3 -3
- package/dist/zoned/format/formatRfc2822.js +3 -3
- package/dist/zoned/format/formatRfc3339.d.ts +2 -2
- package/dist/zoned/format/formatRfc3339.js +2 -2
- package/dist/zoned/format/formatTimeZoneName.d.ts +22 -18
- package/dist/zoned/format/formatTimeZoneName.js +18 -13
- package/dist/zoned/format/formatZonedDateTime.d.ts +10 -10
- package/dist/zoned/format/formatZonedDateTime.js +12 -11
- package/dist/zoned/format/formatZonedRange.d.ts +7 -7
- package/dist/zoned/format/formatZonedRange.js +9 -8
- package/dist/zoned/format/formatZonedToParts.d.ts +11 -11
- package/dist/zoned/format/formatZonedToParts.js +13 -12
- package/dist/zoned/get/getDstTransitions.d.ts +14 -12
- package/dist/zoned/get/getDstTransitions.js +15 -10
- package/dist/zoned/get/getSystemTimeZone.d.ts +5 -3
- package/dist/zoned/get/getSystemTimeZone.js +7 -4
- package/dist/zoned/get/getTimeZoneOffset.d.ts +15 -7
- package/dist/zoned/get/getTimeZoneOffset.js +23 -10
- package/dist/zoned/get/getTimeZones.d.ts +1 -1
- package/dist/zoned/get/getTimeZones.js +1 -1
- package/dist/zoned/get/getZonedDay.d.ts +3 -2
- package/dist/zoned/get/getZonedDay.js +7 -8
- package/dist/zoned/get/getZonedDayOfWeek.d.ts +3 -2
- package/dist/zoned/get/getZonedDayOfWeek.js +7 -6
- package/dist/zoned/get/getZonedHour.d.ts +3 -2
- package/dist/zoned/get/getZonedHour.js +7 -8
- package/dist/zoned/get/getZonedMicrosecond.d.ts +3 -2
- package/dist/zoned/get/getZonedMicrosecond.js +7 -6
- package/dist/zoned/get/getZonedMillisecond.d.ts +3 -2
- package/dist/zoned/get/getZonedMillisecond.js +7 -8
- package/dist/zoned/get/getZonedMinute.d.ts +3 -2
- package/dist/zoned/get/getZonedMinute.js +7 -8
- package/dist/zoned/get/getZonedMonth.d.ts +3 -2
- package/dist/zoned/get/getZonedMonth.js +7 -8
- package/dist/zoned/get/getZonedNanosecond.d.ts +3 -2
- package/dist/zoned/get/getZonedNanosecond.js +7 -6
- package/dist/zoned/get/getZonedNow.d.ts +9 -5
- package/dist/zoned/get/getZonedNow.js +9 -5
- package/dist/zoned/get/getZonedNowUnit.d.ts +7 -4
- package/dist/zoned/get/getZonedNowUnit.js +11 -8
- package/dist/zoned/get/getZonedSecond.d.ts +3 -2
- package/dist/zoned/get/getZonedSecond.js +7 -8
- package/dist/zoned/get/getZonedToday.d.ts +3 -2
- package/dist/zoned/get/getZonedToday.js +7 -6
- package/dist/zoned/get/getZonedWeekOfYear.d.ts +3 -2
- package/dist/zoned/get/getZonedWeekOfYear.js +7 -6
- package/dist/zoned/get/getZonedYear.d.ts +5 -2
- package/dist/zoned/get/getZonedYear.js +10 -8
- package/dist/zoned/index.d.ts +2 -1
- package/dist/zoned/index.js +3 -2
- package/dist/zoned/interval/intervalAbutsZoned.d.ts +2 -2
- package/dist/zoned/interval/intervalAbutsZoned.js +3 -3
- package/dist/zoned/interval/intervalContainsZoned.d.ts +1 -1
- package/dist/zoned/interval/intervalContainsZoned.js +2 -2
- package/dist/zoned/interval/intervalCountZoned.d.ts +4 -4
- package/dist/zoned/interval/intervalCountZoned.js +5 -5
- package/dist/zoned/interval/intervalDifferenceZoned.js +1 -1
- package/dist/zoned/interval/intervalDivideEquallyZoned.d.ts +1 -1
- package/dist/zoned/interval/intervalDivideEquallyZoned.js +2 -2
- package/dist/zoned/interval/intervalEngulfsZoned.d.ts +1 -1
- package/dist/zoned/interval/intervalEngulfsZoned.js +2 -2
- package/dist/zoned/interval/intervalFromDurationZoned.d.ts +6 -6
- package/dist/zoned/interval/intervalFromDurationZoned.js +7 -7
- package/dist/zoned/interval/intervalIntersectionZoned.js +1 -1
- package/dist/zoned/interval/intervalLengthZoned.d.ts +5 -5
- package/dist/zoned/interval/intervalLengthZoned.js +5 -5
- package/dist/zoned/interval/intervalOverlappingDaysZoned.d.ts +2 -2
- package/dist/zoned/interval/intervalOverlappingDaysZoned.js +3 -3
- package/dist/zoned/interval/intervalSplitAtZoned.js +14 -16
- package/dist/zoned/interval/intervalUnionZoned.js +1 -1
- package/dist/zoned/interval/intervalXorAllZoned.js +3 -3
- package/dist/zoned/interval/intervalXorZoned.js +1 -1
- package/dist/zoned/interval/intervalsOverlapZoned.d.ts +2 -2
- package/dist/zoned/interval/intervalsOverlapZoned.js +3 -3
- package/dist/zoned/interval/mergeIntervalsZoned.js +3 -3
- package/dist/zoned/interval/splitIntervalByUnitZoned.d.ts +2 -1
- package/dist/zoned/interval/splitIntervalByUnitZoned.js +3 -2
- package/dist/zoned/interval/validate/isValidCalendarZonedInterval.d.ts +2 -2
- package/dist/zoned/interval/validate/isValidCalendarZonedInterval.js +3 -3
- package/dist/zoned/interval/validate/isValidZonedInterval.d.ts +1 -1
- package/dist/zoned/interval/validate/isValidZonedInterval.js +2 -2
- package/dist/zoned/map/mapZonedDatesInRange.js +1 -1
- package/dist/zoned/map/mapZonedHoursInDay.d.ts +1 -1
- package/dist/zoned/map/mapZonedHoursInDay.js +2 -2
- package/dist/zoned/parse/getZonedOffset.d.ts +1 -1
- package/dist/zoned/parse/getZonedOffset.js +1 -1
- package/dist/zoned/parse/getZonedOffsetAs.d.ts +6 -6
- package/dist/zoned/parse/getZonedOffsetAs.js +3 -3
- package/dist/zoned/parse/parseDateTimeFromZoned.js +2 -2
- package/dist/zoned/parse/parseRfc2822.js +1 -1
- package/dist/zoned/parse/parseRfc3339.js +1 -1
- package/dist/zoned/parse/parseUnitFromZoned.d.ts +5 -2
- package/dist/zoned/parse/parseUnitFromZoned.js +5 -1
- package/dist/zoned/parse/parseYearFromZoned.d.ts +4 -2
- package/dist/zoned/parse/parseYearFromZoned.js +6 -3
- package/dist/zoned/validate/hasDaylightSaving.d.ts +6 -4
- package/dist/zoned/validate/hasDaylightSaving.js +16 -10
- package/dist/zoned/validate/index.d.ts +2 -0
- package/dist/zoned/validate/index.js +2 -0
- package/dist/zoned/validate/isValidCalendarZonedDateTime.d.ts +8 -8
- package/dist/zoned/validate/isValidCalendarZonedDateTime.js +8 -8
- package/dist/zoned/validate/isValidRfc2822DateTime.d.ts +32 -0
- package/dist/zoned/validate/isValidRfc2822DateTime.js +35 -0
- package/dist/zoned/validate/isValidRfc3339DateTime.d.ts +31 -0
- package/dist/zoned/validate/isValidRfc3339DateTime.js +34 -0
- package/dist/zoned/validate/isValidTimeZone.d.ts +6 -2
- package/dist/zoned/validate/isValidTimeZone.js +8 -19
- package/dist/zoned/validate/isValidZonedDateTime.d.ts +7 -7
- package/dist/zoned/validate/isValidZonedDateTime.js +9 -9
- package/dist/zoned/validate/isValidZonedRange.d.ts +1 -1
- package/dist/zoned/validate/isValidZonedRange.js +5 -5
- package/package.json +103 -4
- package/skills/gmt-arithmetic/SKILL.md +63 -17
- package/skills/gmt-basics/SKILL.md +83 -21
- package/skills/gmt-gnss/SKILL.md +92 -0
- package/skills/gmt-integration/SKILL.md +58 -10
- package/skills/gmt-intermodal/SKILL.md +189 -0
- package/skills/gmt-timezone/SKILL.md +51 -169
- package/skills/gmt-transport/SKILL.md +133 -0
- package/skills/gmt-workforce/SKILL.md +84 -0
- package/dist/internal/unixZonedDateTime.d.ts +0 -22
- package/dist/internal/unixZonedDateTime.js +0 -32
- package/dist/internal/utcZonedDateTime.d.ts +0 -19
- package/dist/internal/utcZonedDateTime.js +0 -31
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { Temporal } from "
|
|
1
|
+
import { Temporal } from "./temporal.js";
|
|
2
2
|
import { resolveLocal } from "../instant/convert/resolveLocal.js";
|
|
3
3
|
import { isValidDate } from "../plain/validate/isValidDate.js";
|
|
4
4
|
import { isValidTime } from "../plain/validate/isValidTime.js";
|
|
5
|
-
import { isValidTimeZone } from "../zoned/validate/isValidTimeZone.js";
|
|
6
5
|
import { parseBusinessCalendar, parseHolidays } from "./businessCalendar.js";
|
|
6
|
+
import { epochDayOfDate, hasEpochDay, ISO_WEEKDAYS, isoWeekdayOf, lowerBound, } from "./epochDay.js";
|
|
7
7
|
import { coalesceIntervalNanoseconds, } from "./intervalNanoseconds.js";
|
|
8
|
+
import { MAX_EPOCH_NANOSECONDS, MIN_EPOCH_NANOSECONDS, } from "./epochNanoseconds.js";
|
|
8
9
|
import { isObject, isOptionsArgument } from "./isObject.js";
|
|
10
|
+
import { NANOSECONDS_PER_DAY } from "./foreignEpochs.js";
|
|
11
|
+
import { ensureTimeline, offsetOf, offsetTimeline, resolveWallNs, startOfDayNs, } from "./offsetTimeline.js";
|
|
9
12
|
import { nextZonedBucketStart, zonedUnitStart } from "./zonedBucket.js";
|
|
13
|
+
import { frameEpochNanoseconds, frameWallClock, frameZoned, zoneFrame, } from "./zoneFrame.js";
|
|
10
14
|
const DISAMBIGUATIONS = [
|
|
11
15
|
"compatible",
|
|
12
16
|
"earlier",
|
|
@@ -19,7 +23,7 @@ const WEEKDAY_KEYS = ["1", "2", "3", "4", "5", "6", "7"];
|
|
|
19
23
|
* same bound `bucketRange` puts on a day walk. A walk that runs out answers with the sentinel,
|
|
20
24
|
* never a partial list.
|
|
21
25
|
*/
|
|
22
|
-
|
|
26
|
+
const MAX_SCHEDULE_DAYS = 10_000;
|
|
23
27
|
/**
|
|
24
28
|
* Day buckets one walk may step through: the lookback, the dates, the one date past them that
|
|
25
29
|
* settles the last, and the extra bucket a fall-back into the previous date opens. The date
|
|
@@ -33,20 +37,21 @@ const MAX_SCHEDULE_BUCKETS = 2 * MAX_SCHEDULE_DAYS;
|
|
|
33
37
|
* still be open. Three days clears that with room to spare.
|
|
34
38
|
*/
|
|
35
39
|
const LOOKBACK_NANOSECONDS = 259200000000000n;
|
|
36
|
-
/** TC39 `nsMinInstant` and `nsMaxInstant`: ±10^8 days from the epoch. */
|
|
37
|
-
const MIN_INSTANT_NANOSECONDS = -8640000000000000000000n;
|
|
38
|
-
const MAX_INSTANT_NANOSECONDS = 8640000000000000000000n;
|
|
39
40
|
/**
|
|
40
41
|
* Where an edge whose wall time lies past Temporal's range resolves: just outside it. Such an
|
|
41
42
|
* edge has no string, so it is only ever clipped to a range or compared, never returned.
|
|
42
43
|
*/
|
|
43
|
-
const PAST_LAST_INSTANT =
|
|
44
|
-
const BEFORE_FIRST_INSTANT =
|
|
44
|
+
const PAST_LAST_INSTANT = MAX_EPOCH_NANOSECONDS + 1n;
|
|
45
|
+
const BEFORE_FIRST_INSTANT = MIN_EPOCH_NANOSECONDS - 1n;
|
|
45
46
|
/**
|
|
46
47
|
* The search horizon of `nextOpenAt`, `nextCloseAt` and `addOperatingTime` when the caller
|
|
47
48
|
* gives no `within`: one calendar year in the schedule's zone.
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
|
+
const DEFAULT_OPERATING_HORIZON = "P1Y";
|
|
51
|
+
/** Nanoseconds from midnight to a wall-clock time. */
|
|
52
|
+
function timeOfDayNanoseconds(time) {
|
|
53
|
+
return BigInt(new Temporal.PlainTime().until(time).total("nanoseconds"));
|
|
54
|
+
}
|
|
50
55
|
function parseWindow(value) {
|
|
51
56
|
if (!isObject(value) || Array.isArray(value)) {
|
|
52
57
|
return null;
|
|
@@ -63,6 +68,8 @@ function parseWindow(value) {
|
|
|
63
68
|
return {
|
|
64
69
|
from: fromTime.toString(),
|
|
65
70
|
to: toTime.toString(),
|
|
71
|
+
fromNs: timeOfDayNanoseconds(fromTime),
|
|
72
|
+
toNs: timeOfDayNanoseconds(toTime),
|
|
66
73
|
wraps: Temporal.PlainTime.compare(toTime, fromTime) <= 0,
|
|
67
74
|
};
|
|
68
75
|
}
|
|
@@ -81,9 +88,12 @@ function parseWindows(value) {
|
|
|
81
88
|
return windows;
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
|
-
* Parse `OperatingSchedule['weekly']`: an object
|
|
85
|
-
*
|
|
86
|
-
*
|
|
91
|
+
* Parse `OperatingSchedule['weekly']`: an object keyed by ISO weekday `"1"`–`"7"`, each holding an
|
|
92
|
+
* array of `LocalWindow`s (or `undefined`, meaning closed). Each weekday is read with an ordinary
|
|
93
|
+
* property get, as Temporal's `Get` reads a field list, so a non-enumerable or inherited weekday
|
|
94
|
+
* applies. Any other own enumerable key, string or symbol, or a malformed window, returns `null`;
|
|
95
|
+
* a non-enumerable one is not an entry, as `Object.assign` and spread do not copy it, so a
|
|
96
|
+
* function carrying the weekdays is read without its built-in `length` and `name`.
|
|
87
97
|
*/
|
|
88
98
|
export function parseWeeklyPattern(value) {
|
|
89
99
|
if (!isObject(value) || Array.isArray(value)) {
|
|
@@ -92,13 +102,17 @@ export function parseWeeklyPattern(value) {
|
|
|
92
102
|
const weekly = Array.from({ length: 8 }, () => []);
|
|
93
103
|
const record = value;
|
|
94
104
|
for (const key of Reflect.ownKeys(record)) {
|
|
95
|
-
if (typeof key !== "string" || !WEEKDAY_KEYS.includes(key))
|
|
105
|
+
if ((typeof key !== "string" || !WEEKDAY_KEYS.includes(key)) &&
|
|
106
|
+
Object.prototype.propertyIsEnumerable.call(record, key)) {
|
|
96
107
|
return null;
|
|
97
108
|
}
|
|
98
|
-
|
|
109
|
+
}
|
|
110
|
+
for (const key of WEEKDAY_KEYS) {
|
|
111
|
+
const day = record[key];
|
|
112
|
+
if (day === undefined) {
|
|
99
113
|
continue;
|
|
100
114
|
}
|
|
101
|
-
const windows = parseWindows(
|
|
115
|
+
const windows = parseWindows(day);
|
|
102
116
|
if (windows === null) {
|
|
103
117
|
return null;
|
|
104
118
|
}
|
|
@@ -109,7 +123,7 @@ export function parseWeeklyPattern(value) {
|
|
|
109
123
|
/** `holidays` as a date list or a `BusinessCalendar` (only its `holidays` are read). */
|
|
110
124
|
function parseScheduleHolidays(value) {
|
|
111
125
|
if (value === undefined) {
|
|
112
|
-
return new
|
|
126
|
+
return new Int32Array(0);
|
|
113
127
|
}
|
|
114
128
|
if (Array.isArray(value)) {
|
|
115
129
|
return parseHolidays(value);
|
|
@@ -125,30 +139,37 @@ function parseOverrides(value) {
|
|
|
125
139
|
}
|
|
126
140
|
const overrides = new Map();
|
|
127
141
|
for (const candidate of value) {
|
|
128
|
-
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
const { date, windows } = candidate;
|
|
132
|
-
if (typeof date !== "string" || !isValidDate(date)) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const key = Temporal.PlainDate.from(date).toString();
|
|
136
|
-
const parsed = parseWindows(windows);
|
|
142
|
+
const entry = parseOverride(candidate);
|
|
137
143
|
// Two overrides for one date say two different things about it.
|
|
138
|
-
if (
|
|
144
|
+
if (entry === null || overrides.has(entry[0])) {
|
|
139
145
|
return null;
|
|
140
146
|
}
|
|
141
|
-
overrides.set(
|
|
147
|
+
overrides.set(entry[0], entry[1]);
|
|
142
148
|
}
|
|
143
149
|
return overrides;
|
|
144
150
|
}
|
|
151
|
+
/** One override as its epoch day and windows, or `null` when it is malformed. */
|
|
152
|
+
function parseOverride(candidate) {
|
|
153
|
+
if (!isObject(candidate) || Array.isArray(candidate)) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const { date, windows } = candidate;
|
|
157
|
+
if (typeof date !== "string" || !isValidDate(date)) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
// `isValidDate` accepts only the ISO calendar, so the date has an epoch day.
|
|
161
|
+
const key = epochDayOfDate(Temporal.PlainDate.from(date));
|
|
162
|
+
const parsed = parseWindows(windows);
|
|
163
|
+
return parsed === null ? null : [key, parsed];
|
|
164
|
+
}
|
|
145
165
|
/** Validate an `OperatingSchedule`, or `null` when any part of it is malformed. */
|
|
146
166
|
export function parseOperatingSchedule(value) {
|
|
147
167
|
if (!isObject(value) || Array.isArray(value)) {
|
|
148
168
|
return null;
|
|
149
169
|
}
|
|
150
170
|
const { timeZone, weekly, holidays, overrides } = value;
|
|
151
|
-
|
|
171
|
+
const frame = zoneFrame(timeZone);
|
|
172
|
+
if (typeof timeZone !== "string" || frame === null) {
|
|
152
173
|
return null;
|
|
153
174
|
}
|
|
154
175
|
const weeklyWindows = parseWeeklyPattern(weekly);
|
|
@@ -161,11 +182,21 @@ export function parseOperatingSchedule(value) {
|
|
|
161
182
|
}
|
|
162
183
|
return {
|
|
163
184
|
timeZone,
|
|
185
|
+
frame,
|
|
164
186
|
weekly: weeklyWindows,
|
|
165
187
|
holidays: holidayDates,
|
|
166
188
|
overrides: overrideWindows,
|
|
189
|
+
specials: specialDays(holidayDates, overrideWindows),
|
|
167
190
|
};
|
|
168
191
|
}
|
|
192
|
+
/** The sorted union of the holiday days and the override days. */
|
|
193
|
+
function specialDays(holidays, overrides) {
|
|
194
|
+
const days = new Set(holidays);
|
|
195
|
+
for (const day of overrides.keys()) {
|
|
196
|
+
days.add(day);
|
|
197
|
+
}
|
|
198
|
+
return Int32Array.from(days).sort();
|
|
199
|
+
}
|
|
169
200
|
/**
|
|
170
201
|
* Read `disambiguation` from an options argument. Omitted means `"compatible"`, as in
|
|
171
202
|
* `resolveLocal`; anything but the four Temporal values, or an options argument that is not an
|
|
@@ -192,7 +223,7 @@ export function parseScheduleDisambiguation(options) {
|
|
|
192
223
|
* that instant, since nothing after it can be answered. `null` when `within` is not a
|
|
193
224
|
* non-negative ISO duration.
|
|
194
225
|
*/
|
|
195
|
-
export function parseSearchHorizon(fromNs, within,
|
|
226
|
+
export function parseSearchHorizon(fromNs, within, frame) {
|
|
196
227
|
const text = within === undefined ? DEFAULT_OPERATING_HORIZON : within;
|
|
197
228
|
if (typeof text !== "string") {
|
|
198
229
|
return null;
|
|
@@ -207,31 +238,34 @@ export function parseSearchHorizon(fromNs, within, timeZone) {
|
|
|
207
238
|
if (duration.sign < 0) {
|
|
208
239
|
return null;
|
|
209
240
|
}
|
|
210
|
-
const from = Temporal.Instant.fromEpochNanoseconds(fromNs)
|
|
211
|
-
const horizon = clampedToRange(() => from.add(duration)
|
|
212
|
-
const cap = clampedToRange(() => from
|
|
241
|
+
const from = frameZoned(Temporal.Instant.fromEpochNanoseconds(fromNs), frame);
|
|
242
|
+
const horizon = clampedToRange(() => frameEpochNanoseconds(from.add(duration), frame));
|
|
243
|
+
const cap = clampedToRange(() => frameEpochNanoseconds(from
|
|
213
244
|
.toPlainDate()
|
|
214
245
|
.add({ days: MAX_SCHEDULE_DAYS + 1 })
|
|
215
|
-
.toZonedDateTime(timeZone)
|
|
246
|
+
.toZonedDateTime(frame.timeZone), frame) - 1n);
|
|
216
247
|
return horizon < cap ? horizon : cap;
|
|
217
248
|
}
|
|
218
249
|
/** An instant computed by `instant`, or Temporal's last instant when it lies past the range. */
|
|
219
250
|
function clampedToRange(instant) {
|
|
220
251
|
try {
|
|
221
|
-
|
|
252
|
+
const nanoseconds = instant();
|
|
253
|
+
// At a seconds offset west of UTC the instant is later than the stand-in it was computed
|
|
254
|
+
// on (`frameZoned`), so it can pass the last instant without Temporal throwing.
|
|
255
|
+
return nanoseconds > MAX_EPOCH_NANOSECONDS
|
|
256
|
+
? MAX_EPOCH_NANOSECONDS
|
|
257
|
+
: nanoseconds;
|
|
222
258
|
}
|
|
223
259
|
catch (error) {
|
|
224
260
|
if (error instanceof RangeError) {
|
|
225
|
-
return
|
|
261
|
+
return MAX_EPOCH_NANOSECONDS;
|
|
226
262
|
}
|
|
227
263
|
throw error;
|
|
228
264
|
}
|
|
229
265
|
}
|
|
230
266
|
/** The local date of an instant in the schedule's zone. */
|
|
231
267
|
function localDateOf(schedule, ns) {
|
|
232
|
-
return Temporal.Instant.fromEpochNanoseconds(ns)
|
|
233
|
-
.toZonedDateTimeISO(schedule.timeZone)
|
|
234
|
-
.toPlainDate();
|
|
268
|
+
return frameWallClock(Temporal.Instant.fromEpochNanoseconds(ns), schedule.frame).toPlainDate();
|
|
235
269
|
}
|
|
236
270
|
/**
|
|
237
271
|
* The local date `days` after the one `fromNs` falls on, or `null` when that is past Temporal's
|
|
@@ -250,42 +284,63 @@ function dateLimit(schedule, fromNs, days) {
|
|
|
250
284
|
}
|
|
251
285
|
/**
|
|
252
286
|
* The day bucket the walk starts in: the one holding the instant 72 hours before `fromNs`, or
|
|
253
|
-
*
|
|
254
|
-
* representable, the walk starts at that instant instead, the earliest of its date
|
|
287
|
+
* the earliest instant the schedule's frame can place when that is earlier. When the bucket's own
|
|
288
|
+
* start is not representable, the walk starts at that instant instead, the earliest of its date
|
|
289
|
+
* there is.
|
|
290
|
+
*
|
|
291
|
+
* The earliest instant is Temporal's first, except at an offset with seconds west of UTC: its
|
|
292
|
+
* stand-in sits the offset's seconds before the instant (`frameZoned`), so the first instant it
|
|
293
|
+
* can place is that many seconds after Temporal's first. A walk from before it throws
|
|
294
|
+
* `RangeError`, the caller's sentinel, rather than start after its own instant.
|
|
295
|
+
*
|
|
296
|
+
* `atRangeStart` is true when the walk starts at that earliest instant. No day bucket lies
|
|
297
|
+
* before it, so the windows of the local date before the bucket's own are not reached by walking
|
|
298
|
+
* back: the walk carries them in (`resolveWindowsBefore`).
|
|
255
299
|
*/
|
|
256
300
|
function firstWalkBucket(schedule, fromNs) {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
301
|
+
const shift = schedule.frame.shiftNanoseconds;
|
|
302
|
+
const earliestNs = shift < 0n ? MIN_EPOCH_NANOSECONDS - shift : MIN_EPOCH_NANOSECONDS;
|
|
303
|
+
if (fromNs < earliestNs) {
|
|
304
|
+
throw new RangeError("the instant is before the first the frame can place");
|
|
305
|
+
}
|
|
306
|
+
const atRangeStart = fromNs - LOOKBACK_NANOSECONDS <= earliestNs;
|
|
307
|
+
const startNs = atRangeStart ? earliestNs : fromNs - LOOKBACK_NANOSECONDS;
|
|
308
|
+
const zoned = frameZoned(Temporal.Instant.fromEpochNanoseconds(startNs), schedule.frame);
|
|
261
309
|
try {
|
|
262
|
-
return zonedUnitStart(zoned, "day");
|
|
310
|
+
return { bucket: zonedUnitStart(zoned, "day"), atRangeStart };
|
|
263
311
|
}
|
|
264
312
|
catch (error) {
|
|
265
313
|
if (error instanceof RangeError) {
|
|
266
|
-
return zoned;
|
|
314
|
+
return { bucket: zoned, atRangeStart };
|
|
267
315
|
}
|
|
268
316
|
throw error;
|
|
269
317
|
}
|
|
270
318
|
}
|
|
271
|
-
/** The windows that apply on
|
|
272
|
-
function
|
|
273
|
-
const
|
|
274
|
-
const override = schedule.overrides.get(key);
|
|
319
|
+
/** The windows that apply on an epoch day: an override, else nothing on a holiday, else the weekday's. */
|
|
320
|
+
function windowsOnDay(schedule, epochDay) {
|
|
321
|
+
const override = schedule.overrides.get(epochDay);
|
|
275
322
|
if (override !== undefined) {
|
|
276
323
|
return override;
|
|
277
324
|
}
|
|
278
|
-
return schedule.holidays
|
|
325
|
+
return hasEpochDay(schedule.holidays, epochDay)
|
|
326
|
+
? []
|
|
327
|
+
: schedule.weekly[isoWeekdayOf(epochDay)];
|
|
328
|
+
}
|
|
329
|
+
/** The windows that apply on `date`. */
|
|
330
|
+
function windowsOn(schedule, date) {
|
|
331
|
+
return windowsOnDay(schedule, epochDayOfDate(date));
|
|
279
332
|
}
|
|
280
333
|
/**
|
|
281
|
-
* Resolve one window edge with `resolveLocal`.
|
|
282
|
-
*
|
|
283
|
-
* outside the range, on the side its date lies. `undefined` means `"reject"`
|
|
334
|
+
* Resolve one window edge with `resolveLocal`. An edge on a date Temporal cannot hold is already
|
|
335
|
+
* outside the range. A wall time outside Temporal's range fails under every policy, so it
|
|
336
|
+
* resolves just outside the range, on the side its date lies. `undefined` means `"reject"`
|
|
337
|
+
* refused it.
|
|
284
338
|
*/
|
|
285
|
-
function resolveEdge(
|
|
286
|
-
if (
|
|
287
|
-
return { ns:
|
|
339
|
+
function resolveEdge(edge, timeZone, disambiguation) {
|
|
340
|
+
if (typeof edge === "bigint") {
|
|
341
|
+
return { ns: edge, text: "" };
|
|
288
342
|
}
|
|
343
|
+
const local = `${edge.date.toString()}T${edge.time}`;
|
|
289
344
|
const text = resolveLocal(local, timeZone, { disambiguation });
|
|
290
345
|
if (text !== "") {
|
|
291
346
|
return { ns: Temporal.Instant.from(text).epochNanoseconds, text };
|
|
@@ -294,14 +349,59 @@ function resolveEdge(local, date, timeZone, disambiguation) {
|
|
|
294
349
|
return undefined;
|
|
295
350
|
}
|
|
296
351
|
return {
|
|
297
|
-
ns: date.year > 0 ? PAST_LAST_INSTANT : BEFORE_FIRST_INSTANT,
|
|
352
|
+
ns: edge.date.year > 0 ? PAST_LAST_INSTANT : BEFORE_FIRST_INSTANT,
|
|
298
353
|
text: "",
|
|
299
354
|
};
|
|
300
355
|
}
|
|
356
|
+
/** The local date after `date`, or `null` past Temporal's last date. */
|
|
357
|
+
function dateAfter(date) {
|
|
358
|
+
try {
|
|
359
|
+
return date.add({ days: 1 });
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
if (error instanceof RangeError) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/** The local date before `date`, or `null` before Temporal's first date. */
|
|
369
|
+
function dateBefore(date) {
|
|
370
|
+
try {
|
|
371
|
+
return date.subtract({ days: 1 });
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
if (error instanceof RangeError) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
throw error;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/** The widest span a window with an unresolved edge could cover: its start `"earlier"`, its end `"later"`. */
|
|
381
|
+
function widestSpan(startEdge, endEdge, timeZone) {
|
|
382
|
+
// "earlier" and "later" always resolve, so the widest span is always known.
|
|
383
|
+
return {
|
|
384
|
+
start: resolveEdge(startEdge, timeZone, "earlier")?.ns ?? BEFORE_FIRST_INSTANT,
|
|
385
|
+
end: resolveEdge(endEdge, timeZone, "later")?.ns ?? PAST_LAST_INSTANT,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
/** Where a window ends: its `to` on its own date, or on the next if it wraps midnight. */
|
|
389
|
+
function windowEndEdge(window, date, next) {
|
|
390
|
+
const endDate = window.wraps ? next : date;
|
|
391
|
+
if (endDate !== null) {
|
|
392
|
+
return { date: endDate, time: window.to };
|
|
393
|
+
}
|
|
394
|
+
return window.wraps ? PAST_LAST_INSTANT : BEFORE_FIRST_INSTANT;
|
|
395
|
+
}
|
|
301
396
|
/**
|
|
302
|
-
* Resolve one date
|
|
303
|
-
* under `disambiguation`; a wrapping window's `to` is read on the next date. An edge pair
|
|
304
|
-
* resolves to an empty or inverted span (a window shorter than the gap it straddles) is
|
|
397
|
+
* Resolve the windows of one local date to instants with `resolveLocal`. Each edge is resolved on
|
|
398
|
+
* its own under `disambiguation`; a wrapping window's `to` is read on the next date. An edge pair
|
|
399
|
+
* that resolves to an empty or inverted span (a window shorter than the gap it straddles) is
|
|
400
|
+
* dropped.
|
|
401
|
+
*
|
|
402
|
+
* `date` is `null` for the date before Temporal's first, and `next` is `null` for the date after
|
|
403
|
+
* its last. A window is a rule about the local clock, so it still holds on the side of it that
|
|
404
|
+
* Temporal can reach: an edge on a date Temporal cannot hold lies just outside the range.
|
|
305
405
|
*
|
|
306
406
|
* Under `"earlier"`, an edge in a gap moves back by the gap's length (TC39
|
|
307
407
|
* DisambiguatePossibleEpochNanoseconds), so a date whose midnight is skipped can open before its
|
|
@@ -312,35 +412,17 @@ function resolveEdge(local, date, timeZone, disambiguation) {
|
|
|
312
412
|
* in `unresolved` as the widest span it could cover (its start read `"earlier"`, its end
|
|
313
413
|
* `"later"`), so the caller can refuse an answer it might change and ignore it elsewhere.
|
|
314
414
|
*/
|
|
315
|
-
function resolveDateWindows(schedule, date, disambiguation) {
|
|
415
|
+
function resolveDateWindows(schedule, windows, date, next, disambiguation) {
|
|
316
416
|
const records = [];
|
|
317
417
|
const unresolved = [];
|
|
318
418
|
const { timeZone } = schedule;
|
|
319
|
-
for (const window of
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
catch (error) {
|
|
326
|
-
if (!(error instanceof RangeError)) {
|
|
327
|
-
throw error;
|
|
328
|
-
}
|
|
329
|
-
endDate = null;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
const startLocal = `${date.toString()}T${window.from}`;
|
|
333
|
-
const endLocal = endDate === null ? null : `${endDate.toString()}T${window.to}`;
|
|
334
|
-
const start = resolveEdge(startLocal, date, timeZone, disambiguation);
|
|
335
|
-
const end = resolveEdge(endLocal, endDate ?? date, timeZone, disambiguation);
|
|
419
|
+
for (const window of windows) {
|
|
420
|
+
const startEdge = date === null ? BEFORE_FIRST_INSTANT : { date, time: window.from };
|
|
421
|
+
const endEdge = windowEndEdge(window, date, next);
|
|
422
|
+
const start = resolveEdge(startEdge, timeZone, disambiguation);
|
|
423
|
+
const end = resolveEdge(endEdge, timeZone, disambiguation);
|
|
336
424
|
if (start === undefined || end === undefined) {
|
|
337
|
-
|
|
338
|
-
const earliest = resolveEdge(startLocal, date, timeZone, "earlier");
|
|
339
|
-
const latest = resolveEdge(endLocal, endDate ?? date, timeZone, "later");
|
|
340
|
-
unresolved.push({
|
|
341
|
-
start: earliest?.ns ?? BEFORE_FIRST_INSTANT,
|
|
342
|
-
end: latest?.ns ?? PAST_LAST_INSTANT,
|
|
343
|
-
});
|
|
425
|
+
unresolved.push(widestSpan(startEdge, endEdge, timeZone));
|
|
344
426
|
continue;
|
|
345
427
|
}
|
|
346
428
|
if (start.ns < end.ns) {
|
|
@@ -355,25 +437,42 @@ function resolveDateWindows(schedule, date, disambiguation) {
|
|
|
355
437
|
return { records, unresolved };
|
|
356
438
|
}
|
|
357
439
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
440
|
+
* Resolve the windows of the local date before `date`, the first date of a walk that starts at
|
|
441
|
+
* the earliest instant its frame can place.
|
|
360
442
|
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
443
|
+
* A window that opened on that date and wraps past midnight is still open on `date`, although
|
|
444
|
+
* the instant it opened at is before the range. The previous date follows its own override or
|
|
445
|
+
* holiday like any other. West of UTC the first date is Temporal's first, `-271821-04-19`, and
|
|
446
|
+
* the date before it cannot be held or named: no override or holiday can be written for it, so
|
|
447
|
+
* the weekly pattern applies, by the weekday before `date`'s.
|
|
448
|
+
*/
|
|
449
|
+
function resolveWindowsBefore(schedule, date, disambiguation) {
|
|
450
|
+
const previous = dateBefore(date);
|
|
451
|
+
const windows = previous === null
|
|
452
|
+
? schedule.weekly[date.dayOfWeek === 1 ? 7 : date.dayOfWeek - 1]
|
|
453
|
+
: windowsOn(schedule, previous);
|
|
454
|
+
return resolveDateWindows(schedule, windows, previous, date, disambiguation);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Resolve the windows a walk gains on reaching `date`: the date's own and, for the first date of
|
|
458
|
+
* a walk from the start of the range (`carryIn`), those of the date before it.
|
|
373
459
|
*/
|
|
374
|
-
|
|
460
|
+
function resolveVisit(schedule, date, carryIn, disambiguation) {
|
|
461
|
+
const own = resolveDateWindows(schedule, windowsOn(schedule, date), date, dateAfter(date), disambiguation);
|
|
462
|
+
if (!carryIn) {
|
|
463
|
+
return own;
|
|
464
|
+
}
|
|
465
|
+
const before = resolveWindowsBefore(schedule, date, disambiguation);
|
|
466
|
+
return {
|
|
467
|
+
records: [...before.records, ...own.records],
|
|
468
|
+
unresolved: [...before.unresolved, ...own.unresolved],
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/** The state a walk shares between the two ways of reaching dates: pending runs and the bound. */
|
|
472
|
+
function startWalk(fromNs, visitor) {
|
|
375
473
|
let pending = [];
|
|
376
474
|
let unresolvedStart;
|
|
475
|
+
let bound;
|
|
377
476
|
const finish = () => ({ unresolvedStart });
|
|
378
477
|
const flush = () => {
|
|
379
478
|
for (const run of pending) {
|
|
@@ -383,17 +482,16 @@ export function walkSchedule(schedule, fromNs, disambiguation, visitor) {
|
|
|
383
482
|
}
|
|
384
483
|
return finish();
|
|
385
484
|
};
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (bound !== undefined) {
|
|
485
|
+
return {
|
|
486
|
+
flush,
|
|
487
|
+
/**
|
|
488
|
+
* Hand the visitor the runs no later window can extend, and announce the bound. Returns the
|
|
489
|
+
* walk's result when the visitor stops it, else `undefined`.
|
|
490
|
+
*/
|
|
491
|
+
settle() {
|
|
492
|
+
if (bound === undefined) {
|
|
493
|
+
return undefined;
|
|
494
|
+
}
|
|
397
495
|
const settleBefore = bound;
|
|
398
496
|
for (const run of pending) {
|
|
399
497
|
if (run.end >= settleBefore) {
|
|
@@ -404,56 +502,212 @@ export function walkSchedule(schedule, fromNs, disambiguation, visitor) {
|
|
|
404
502
|
}
|
|
405
503
|
}
|
|
406
504
|
pending = pending.filter((run) => run.end >= settleBefore);
|
|
407
|
-
|
|
408
|
-
|
|
505
|
+
return visitor.day(settleBefore, pending) ? flush() : undefined;
|
|
506
|
+
},
|
|
507
|
+
/** Take a date's windows; `start` is the first instant of the date. */
|
|
508
|
+
add(resolved, start) {
|
|
509
|
+
for (const window of resolved.unresolved) {
|
|
510
|
+
if (window.end > fromNs &&
|
|
511
|
+
(unresolvedStart === undefined || window.start < unresolvedStart)) {
|
|
512
|
+
unresolvedStart = window.start;
|
|
513
|
+
}
|
|
409
514
|
}
|
|
515
|
+
pending = coalesceIntervalNanoseconds([...pending, ...resolved.records]);
|
|
516
|
+
bound = start;
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Walk the schedule's local dates from a little before `fromNs`, handing the visitor each open
|
|
522
|
+
* run as soon as no later window can extend it.
|
|
523
|
+
*
|
|
524
|
+
* - Dates come from the day buckets `floorToZone` and `bucketRange` use, so a deleted date
|
|
525
|
+
* (`Pacific/Apia`, 2011-12-30) is never visited, and a date the clock re-enters after a
|
|
526
|
+
* fall-back (`America/Goose_Bay`, 2010-11-06) is visited once.
|
|
527
|
+
* - A window can start as early as the previous date's first instant (see `resolveDateWindows`),
|
|
528
|
+
* so the walk settles one date behind: once a date is resolved, the first instant of the date
|
|
529
|
+
* resolved before it is the `bound` no later window starts before.
|
|
530
|
+
* - A walk from the start of Temporal's range also resolves the date before its first, whose
|
|
531
|
+
* wrapping windows are still open when the range begins (`resolveWindowsBefore`).
|
|
532
|
+
* - When the visitor stops the walk from `day`, or the last representable day is reached, the
|
|
533
|
+
* runs still pending are handed over too.
|
|
534
|
+
* - Returns `null` when a day bucket could not be found, or the walk would resolve a date
|
|
535
|
+
* `MAX_SCHEDULE_DAYS + 2` after the one `fromNs` falls on. Neither use reaches that: a range
|
|
536
|
+
* is refused up front past `MAX_SCHEDULE_DAYS` dates, and a search's horizon ends with the
|
|
537
|
+
* `MAX_SCHEDULE_DAYS`th date, so its walk stops by the horizon one date later.
|
|
538
|
+
*/
|
|
539
|
+
function walkSchedule(schedule, fromNs, disambiguation, visitor, timeline) {
|
|
540
|
+
return walkNearsLimits(fromNs)
|
|
541
|
+
? walkScheduleByBuckets(schedule, fromNs, disambiguation, visitor)
|
|
542
|
+
: walkScheduleByDays(schedule, fromNs, disambiguation, visitor, timeline);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* `walkSchedule` date by date through Temporal, for a walk that could come near Temporal's limits,
|
|
546
|
+
* where every date, bucket and wall time keeps the range rules (`resolveEdge`).
|
|
547
|
+
*/
|
|
548
|
+
function walkScheduleByBuckets(schedule, fromNs, disambiguation, visitor) {
|
|
549
|
+
const walk = startWalk(fromNs, visitor);
|
|
550
|
+
// The span a range or search may cover, plus the date after its last, which is resolved to
|
|
551
|
+
// settle it because its windows can start before its own first instant.
|
|
552
|
+
const limitDate = dateLimit(schedule, fromNs, MAX_SCHEDULE_DAYS + 2);
|
|
553
|
+
const first = firstWalkBucket(schedule, fromNs);
|
|
554
|
+
let current = first.bucket;
|
|
555
|
+
// True until the first date is resolved, for a walk from the start of the range.
|
|
556
|
+
let carryIn = first.atRangeStart;
|
|
557
|
+
let lastDate = null;
|
|
558
|
+
for (let bucket = 0; bucket < MAX_SCHEDULE_BUCKETS; bucket++) {
|
|
559
|
+
if (current === null) {
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
const stopped = walk.settle();
|
|
563
|
+
if (stopped !== undefined) {
|
|
564
|
+
return stopped;
|
|
410
565
|
}
|
|
411
566
|
const date = current.toPlainDate();
|
|
412
567
|
// A fall-back that re-enters the previous date opens a second bucket for it; its windows
|
|
413
568
|
// were already resolved on the first visit.
|
|
414
569
|
if (lastDate === null || Temporal.PlainDate.compare(date, lastDate) > 0) {
|
|
415
|
-
if (limitDate
|
|
416
|
-
Temporal.PlainDate.compare(date, limitDate) >= 0) {
|
|
570
|
+
if (isFromDate(date, limitDate)) {
|
|
417
571
|
return null;
|
|
418
572
|
}
|
|
419
|
-
const resolved =
|
|
420
|
-
|
|
421
|
-
if (window.end > fromNs &&
|
|
422
|
-
(unresolvedStart === undefined || window.start < unresolvedStart)) {
|
|
423
|
-
unresolvedStart = window.start;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
pending = coalesceIntervalNanoseconds([...pending, ...resolved.records]);
|
|
573
|
+
const resolved = resolveVisit(schedule, date, carryIn, disambiguation);
|
|
574
|
+
carryIn = false;
|
|
427
575
|
lastDate = date;
|
|
428
|
-
|
|
576
|
+
walk.add(resolved, frameEpochNanoseconds(current, schedule.frame));
|
|
429
577
|
}
|
|
430
|
-
|
|
431
|
-
|
|
578
|
+
const following = nextDayBucket(current);
|
|
579
|
+
// The next day starts past Temporal's last instant: nothing more can open.
|
|
580
|
+
if (following === undefined) {
|
|
581
|
+
return walk.flush();
|
|
432
582
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
583
|
+
current = following;
|
|
584
|
+
}
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
/** True when `date` is `limit` or later; never when there is no limit. */
|
|
588
|
+
function isFromDate(date, limit) {
|
|
589
|
+
return limit !== null && Temporal.PlainDate.compare(date, limit) >= 0;
|
|
590
|
+
}
|
|
591
|
+
/** The bucket of the next day, or `undefined` when it starts past Temporal's last instant. */
|
|
592
|
+
function nextDayBucket(current) {
|
|
593
|
+
try {
|
|
594
|
+
return nextZonedBucketStart(current, "day");
|
|
595
|
+
}
|
|
596
|
+
catch (error) {
|
|
597
|
+
if (error instanceof RangeError) {
|
|
598
|
+
return undefined;
|
|
599
|
+
}
|
|
600
|
+
throw error;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Walk dates as epoch days read from the offset timeline, without a `ZonedDateTime` per date.
|
|
605
|
+
* Same contract as `walkScheduleByBuckets`, for a walk that stays clear of Temporal's limits.
|
|
606
|
+
* `shared` is a timeline a caller already built that reaches at least nine days before `fromNs`,
|
|
607
|
+
* so pieces of one range read the zone's offset changes once.
|
|
608
|
+
* Dates ascend and are visited once: a date whose first instant is the next date's (a deleted
|
|
609
|
+
* date, `Pacific/Apia` 2011-12-30) is skipped, and a re-entered date (`America/Goose_Bay`
|
|
610
|
+
* 2010-11-06) is one date.
|
|
611
|
+
*/
|
|
612
|
+
function walkScheduleByDays(schedule, fromNs, disambiguation, visitor, shared) {
|
|
613
|
+
const walk = startWalk(fromNs, visitor);
|
|
614
|
+
const startNs = fromNs - LOOKBACK_NANOSECONDS;
|
|
615
|
+
const timeline = shared ??
|
|
616
|
+
offsetTimeline(schedule.frame, startNs - 6n * NANOSECONDS_PER_DAY, startNs + 14n * NANOSECONDS_PER_DAY);
|
|
617
|
+
const limitDay = localDayOf(timeline, fromNs) + MAX_SCHEDULE_DAYS + 2;
|
|
618
|
+
let day = localDayOf(timeline, startNs);
|
|
619
|
+
for (let count = 0; count < MAX_SCHEDULE_BUCKETS; count++, day++) {
|
|
620
|
+
ensureTimeline(timeline, BigInt(day + 6) * NANOSECONDS_PER_DAY);
|
|
621
|
+
const start = startOfDayNs(timeline, day);
|
|
622
|
+
if (start === startOfDayNs(timeline, day + 1)) {
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
const stopped = walk.settle();
|
|
626
|
+
if (stopped !== undefined) {
|
|
627
|
+
return stopped;
|
|
628
|
+
}
|
|
629
|
+
if (day >= limitDay) {
|
|
630
|
+
return null;
|
|
439
631
|
}
|
|
632
|
+
walk.add(resolveDayWindows(windowsOnDay(schedule, day), timeline, day, disambiguation), start);
|
|
440
633
|
}
|
|
441
634
|
return null;
|
|
442
635
|
}
|
|
636
|
+
/** The local epoch day `ns` falls on in the timeline's frame. */
|
|
637
|
+
function localDayOf(timeline, ns) {
|
|
638
|
+
return Number(floorDivide(ns + offsetOf(timeline, ns), NANOSECONDS_PER_DAY));
|
|
639
|
+
}
|
|
640
|
+
/** `resolveDateWindows` for a date well inside Temporal's range, read from the timeline. */
|
|
641
|
+
function resolveDayWindows(windows, timeline, day, disambiguation) {
|
|
642
|
+
const records = [];
|
|
643
|
+
const unresolved = [];
|
|
644
|
+
const midnight = BigInt(day) * NANOSECONDS_PER_DAY;
|
|
645
|
+
for (const window of windows) {
|
|
646
|
+
const startWall = midnight + window.fromNs;
|
|
647
|
+
const endWall = (window.wraps ? midnight + NANOSECONDS_PER_DAY : midnight) + window.toNs;
|
|
648
|
+
const start = resolveWallNs(timeline, startWall, disambiguation);
|
|
649
|
+
const end = resolveWallNs(timeline, endWall, disambiguation);
|
|
650
|
+
if (start === undefined || end === undefined) {
|
|
651
|
+
unresolved.push({
|
|
652
|
+
start: resolveWallNs(timeline, startWall, "earlier") ?? BEFORE_FIRST_INSTANT,
|
|
653
|
+
end: resolveWallNs(timeline, endWall, "later") ?? PAST_LAST_INSTANT,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
else if (start < end) {
|
|
657
|
+
// The text of an edge is written when a run is returned (`runText`).
|
|
658
|
+
records.push({ start, end, startText: "", endText: "" });
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return { records, unresolved };
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Days either side of Temporal's range that the closed forms and the date walk keep clear of;
|
|
665
|
+
* a walk that could come nearer takes the date-by-date path, which reads the limits itself.
|
|
666
|
+
*/
|
|
667
|
+
const LIMIT_MARGIN = 30n * NANOSECONDS_PER_DAY;
|
|
668
|
+
/** True when a walk from `fromNs` could reach within `LIMIT_MARGIN` of Temporal's range. */
|
|
669
|
+
function walkNearsLimits(fromNs) {
|
|
670
|
+
return (fromNs - LOOKBACK_NANOSECONDS - LIMIT_MARGIN < MIN_EPOCH_NANOSECONDS ||
|
|
671
|
+
fromNs +
|
|
672
|
+
BigInt(MAX_SCHEDULE_DAYS + 3) * NANOSECONDS_PER_DAY +
|
|
673
|
+
LIMIT_MARGIN >
|
|
674
|
+
MAX_EPOCH_NANOSECONDS);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* True when a range spans more than MAX_SCHEDULE_DAYS local dates: it is refused before walking.
|
|
678
|
+
* Walking thousands of dates only to return the sentinel took seconds.
|
|
679
|
+
*/
|
|
680
|
+
function spansTooManyDates(schedule, range) {
|
|
681
|
+
const lastInstant = range.end > range.start ? range.end - 1n : range.end;
|
|
682
|
+
const limit = dateLimit(schedule, range.start, MAX_SCHEDULE_DAYS);
|
|
683
|
+
return (limit !== null &&
|
|
684
|
+
Temporal.PlainDate.compare(localDateOf(schedule, lastInstant), limit) >= 0);
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* The text of a run's edges: the range's own where the run was clipped to it, else the instant's
|
|
688
|
+
* UTC string, written here and only for the runs a caller returns.
|
|
689
|
+
*/
|
|
690
|
+
export function runText(run) {
|
|
691
|
+
return {
|
|
692
|
+
start: run.startText === "" ? instantText(run.start) : run.startText,
|
|
693
|
+
end: run.endText === "" ? instantText(run.end) : run.endText,
|
|
694
|
+
};
|
|
695
|
+
}
|
|
443
696
|
/**
|
|
444
697
|
* The schedule's open runs clipped to `[startNs, endNs)`, in the range's own strings where a run
|
|
445
698
|
* is clipped. `null` when the walk fails (see `walkSchedule`), or when a window rejected under
|
|
446
699
|
* `"reject"` reaches into the range.
|
|
447
700
|
*/
|
|
448
701
|
export function scheduleRunsWithin(schedule, range, disambiguation) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
702
|
+
return spansTooManyDates(schedule, range)
|
|
703
|
+
? null
|
|
704
|
+
: walkedRunsWithin(schedule, range, disambiguation);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* `scheduleRunsWithin` for a range already known to span few enough local dates, as every piece
|
|
708
|
+
* of such a range does: a piece starts no earlier and ends no later, so it cannot reach the limit.
|
|
709
|
+
*/
|
|
710
|
+
function walkedRunsWithin(schedule, range, disambiguation, timeline) {
|
|
457
711
|
const runs = [];
|
|
458
712
|
const walked = walkSchedule(schedule, range.start, disambiguation, {
|
|
459
713
|
run: (run) => {
|
|
@@ -473,7 +727,7 @@ export function scheduleRunsWithin(schedule, range, disambiguation) {
|
|
|
473
727
|
return false;
|
|
474
728
|
},
|
|
475
729
|
day: (bound) => bound >= range.end,
|
|
476
|
-
});
|
|
730
|
+
}, timeline);
|
|
477
731
|
if (walked === null ||
|
|
478
732
|
(walked.unresolvedStart !== undefined && walked.unresolvedStart < range.end)) {
|
|
479
733
|
return null;
|
|
@@ -485,44 +739,50 @@ function later(a, b) {
|
|
|
485
739
|
return a > b ? a : b;
|
|
486
740
|
}
|
|
487
741
|
/**
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
* sooner.
|
|
742
|
+
* Walk from `fromNs` until a caller can answer. `atRun` sees each finished run that ends after
|
|
743
|
+
* `fromNs`, and `atDay` the first pending run that does when no later window can start before
|
|
744
|
+
* `bound`; each returns the answer, or `undefined` to keep walking. Past `horizonNs` the walk
|
|
745
|
+
* stops unanswered. `null` when the walk fails.
|
|
493
746
|
*/
|
|
494
|
-
|
|
747
|
+
function firstAnswer(schedule, fromNs, horizonNs, disambiguation, atRun, atDay) {
|
|
495
748
|
let answer;
|
|
496
749
|
const walked = walkSchedule(schedule, fromNs, disambiguation, {
|
|
497
750
|
run: (run) => {
|
|
498
|
-
if (answer
|
|
499
|
-
|
|
751
|
+
if (answer === undefined && run.end > fromNs) {
|
|
752
|
+
answer = atRun(run);
|
|
500
753
|
}
|
|
501
|
-
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
answer = later(run.start, fromNs);
|
|
505
|
-
return true;
|
|
754
|
+
return answer !== undefined;
|
|
506
755
|
},
|
|
507
756
|
day: (bound, pending) => {
|
|
508
757
|
if (bound > horizonNs) {
|
|
509
758
|
return true;
|
|
510
759
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
answer = later(next.start, fromNs);
|
|
514
|
-
return true;
|
|
515
|
-
}
|
|
516
|
-
return false;
|
|
760
|
+
answer = atDay(bound, pending.find((run) => run.end > fromNs));
|
|
761
|
+
return answer !== undefined;
|
|
517
762
|
},
|
|
518
763
|
});
|
|
764
|
+
return walked === null
|
|
765
|
+
? null
|
|
766
|
+
: { answer, unresolvedStart: walked.unresolvedStart };
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The first instant at or after `fromNs` that the schedule is open: `fromNs` itself inside an
|
|
770
|
+
* open run, else the start of the next run. Answered as soon as no later window can open
|
|
771
|
+
* sooner, without waiting for the run to close. `undefined` when none falls at or before
|
|
772
|
+
* `horizonNs`, `null` when the walk fails or a window rejected under `"reject"` could open
|
|
773
|
+
* sooner.
|
|
774
|
+
*/
|
|
775
|
+
export function firstOpenInstant(schedule, fromNs, horizonNs, disambiguation) {
|
|
776
|
+
const walked = firstAnswer(schedule, fromNs, horizonNs, disambiguation, (run) => later(run.start, fromNs), (bound, next) => next !== undefined && later(next.start, fromNs) <= bound
|
|
777
|
+
? later(next.start, fromNs)
|
|
778
|
+
: undefined);
|
|
519
779
|
if (walked === null) {
|
|
520
780
|
return null;
|
|
521
781
|
}
|
|
782
|
+
const { answer, unresolvedStart } = walked;
|
|
522
783
|
if (answer === undefined || answer > horizonNs) {
|
|
523
784
|
return undefined;
|
|
524
785
|
}
|
|
525
|
-
const { unresolvedStart } = walked;
|
|
526
786
|
return answer > fromNs &&
|
|
527
787
|
unresolvedStart !== undefined &&
|
|
528
788
|
unresolvedStart < answer
|
|
@@ -536,35 +796,15 @@ export function firstOpenInstant(schedule, fromNs, horizonNs, disambiguation) {
|
|
|
536
796
|
* the walk fails or a window rejected under `"reject"` could keep the schedule open past it.
|
|
537
797
|
*/
|
|
538
798
|
export function firstClosedInstant(schedule, fromNs, horizonNs, disambiguation) {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
if (run.end <= fromNs) {
|
|
546
|
-
return false;
|
|
547
|
-
}
|
|
548
|
-
answer = run.start <= fromNs ? run.end : fromNs;
|
|
549
|
-
return true;
|
|
550
|
-
},
|
|
551
|
-
day: (bound, pending) => {
|
|
552
|
-
if (bound > horizonNs) {
|
|
553
|
-
return true;
|
|
554
|
-
}
|
|
555
|
-
const next = pending.find((run) => run.end > fromNs);
|
|
556
|
-
// Closed at `fromNs`, and every later window starts after it.
|
|
557
|
-
if (fromNs < bound && (next === undefined || next.start > fromNs)) {
|
|
558
|
-
answer = fromNs;
|
|
559
|
-
return true;
|
|
560
|
-
}
|
|
561
|
-
return false;
|
|
562
|
-
},
|
|
563
|
-
});
|
|
799
|
+
const walked = firstAnswer(schedule, fromNs, horizonNs, disambiguation, (run) => (run.start <= fromNs ? run.end : fromNs),
|
|
800
|
+
// Closed at `fromNs`, and every later window starts after it.
|
|
801
|
+
(bound, next) => fromNs < bound && (next === undefined || next.start > fromNs)
|
|
802
|
+
? fromNs
|
|
803
|
+
: undefined);
|
|
564
804
|
if (walked === null) {
|
|
565
805
|
return null;
|
|
566
806
|
}
|
|
567
|
-
const closed = answer ?? fromNs;
|
|
807
|
+
const closed = walked.answer ?? fromNs;
|
|
568
808
|
if (closed > horizonNs) {
|
|
569
809
|
return undefined;
|
|
570
810
|
}
|
|
@@ -584,48 +824,36 @@ export function instantAfterOpenTime(schedule, fromNs, amountNs, horizonNs, disa
|
|
|
584
824
|
if (amountNs === 0n) {
|
|
585
825
|
return fromNs;
|
|
586
826
|
}
|
|
827
|
+
const jump = jumpOverWholeDays(schedule, fromNs, amountNs, horizonNs, disambiguation);
|
|
828
|
+
return walkForOpenTime(schedule, jump?.startNs ?? fromNs, jump?.remaining ?? amountNs, horizonNs, disambiguation);
|
|
829
|
+
}
|
|
830
|
+
/** `instantAfterOpenTime` by walking dates from `fromNs`. */
|
|
831
|
+
function walkForOpenTime(schedule, fromNs, amountNs, horizonNs, disambiguation) {
|
|
587
832
|
let remaining = amountNs;
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
},
|
|
605
|
-
day: (bound, pending) => {
|
|
606
|
-
if (bound > horizonNs) {
|
|
607
|
-
return true;
|
|
608
|
-
}
|
|
609
|
-
// Every pending run ends at or after `bound`, so only the first can hold a deadline at or
|
|
610
|
-
// before it; open time before `bound` is final.
|
|
611
|
-
const next = pending.find((run) => run.end > fromNs);
|
|
612
|
-
if (next !== undefined) {
|
|
613
|
-
const deadline = later(next.start, fromNs) + remaining;
|
|
614
|
-
if (deadline <= next.end && deadline <= bound) {
|
|
615
|
-
answer = deadline;
|
|
616
|
-
return true;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
return false;
|
|
620
|
-
},
|
|
833
|
+
const walked = firstAnswer(schedule, fromNs, horizonNs, disambiguation, (run) => {
|
|
834
|
+
const start = later(run.start, fromNs);
|
|
835
|
+
if (run.end - start >= remaining) {
|
|
836
|
+
return start + remaining;
|
|
837
|
+
}
|
|
838
|
+
remaining -= run.end - start;
|
|
839
|
+
return undefined;
|
|
840
|
+
},
|
|
841
|
+
// Every pending run ends at or after `bound`, so only the first can hold a deadline at or
|
|
842
|
+
// before it; open time before `bound` is final.
|
|
843
|
+
(bound, next) => {
|
|
844
|
+
if (next === undefined) {
|
|
845
|
+
return undefined;
|
|
846
|
+
}
|
|
847
|
+
const deadline = later(next.start, fromNs) + remaining;
|
|
848
|
+
return deadline <= next.end && deadline <= bound ? deadline : undefined;
|
|
621
849
|
});
|
|
622
850
|
if (walked === null) {
|
|
623
851
|
return null;
|
|
624
852
|
}
|
|
853
|
+
const { answer, unresolvedStart } = walked;
|
|
625
854
|
if (answer === undefined || answer > horizonNs) {
|
|
626
855
|
return undefined;
|
|
627
856
|
}
|
|
628
|
-
const { unresolvedStart } = walked;
|
|
629
857
|
return unresolvedStart !== undefined && unresolvedStart < answer
|
|
630
858
|
? null
|
|
631
859
|
: answer;
|
|
@@ -666,3 +894,225 @@ export function parseOpenTimeAmount(value) {
|
|
|
666
894
|
export function instantText(nanoseconds) {
|
|
667
895
|
return Temporal.Instant.fromEpochNanoseconds(nanoseconds).toString();
|
|
668
896
|
}
|
|
897
|
+
/** `a / b` rounded toward negative infinity, for a positive `b`. */
|
|
898
|
+
function floorDivide(a, b) {
|
|
899
|
+
const quotient = a / b;
|
|
900
|
+
return a % b < 0n ? quotient - 1n : quotient;
|
|
901
|
+
}
|
|
902
|
+
/** `a / b` rounded toward positive infinity, for a positive `b`. */
|
|
903
|
+
function ceilDivide(a, b) {
|
|
904
|
+
return -floorDivide(-a, b);
|
|
905
|
+
}
|
|
906
|
+
/** Length of the union of `spans`, each `[start, end)`. */
|
|
907
|
+
function unionLength(spans) {
|
|
908
|
+
spans.sort((x, y) => (x[0] < y[0] ? -1 : x[0] > y[0] ? 1 : 0));
|
|
909
|
+
let total = 0n;
|
|
910
|
+
let reached = 0n;
|
|
911
|
+
for (const [start, end] of spans) {
|
|
912
|
+
const from = start > reached ? start : reached;
|
|
913
|
+
if (end > from) {
|
|
914
|
+
total += end - from;
|
|
915
|
+
reached = end;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return total;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Open time inside the day bucket of a quiet date: the tails of the previous date's wrapping
|
|
922
|
+
* windows (`[0, to)`) and the date's own windows (`[from, to)`, or `[from, 1 day)` when wrapping),
|
|
923
|
+
* as a union.
|
|
924
|
+
*/
|
|
925
|
+
function dayCoverage(previous, current) {
|
|
926
|
+
const spans = [];
|
|
927
|
+
for (const window of previous) {
|
|
928
|
+
if (window.wraps) {
|
|
929
|
+
spans.push([0n, window.toNs]);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
for (const window of current) {
|
|
933
|
+
spans.push([
|
|
934
|
+
window.fromNs,
|
|
935
|
+
window.wraps ? NANOSECONDS_PER_DAY : window.toNs,
|
|
936
|
+
]);
|
|
937
|
+
}
|
|
938
|
+
return unionLength(spans);
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* The maximal blocks of quiet dates lying wholly inside `range`, ascending. A date `d` is quiet
|
|
942
|
+
* when one stretch, offset `o`, holds every instant from `(d - 2)` days `- o` to `(d + 3)` days
|
|
943
|
+
* `- o`: every wall time on `d - 1`, `d` and `d + 1` then has the one candidate `wall - o` under
|
|
944
|
+
* every policy, and `d`'s bucket is exactly one day. A refused edge has a change within a day of
|
|
945
|
+
* it, so none reaches a quiet date.
|
|
946
|
+
*/
|
|
947
|
+
function quietBlocks(timeline, range) {
|
|
948
|
+
const { changes, offsets } = timeline;
|
|
949
|
+
const day = NANOSECONDS_PER_DAY;
|
|
950
|
+
const blocks = [];
|
|
951
|
+
for (let index = 0; index < offsets.length; index++) {
|
|
952
|
+
const offset = offsets[index];
|
|
953
|
+
const low = index === 0 ? timeline.fromNs : changes[index - 1];
|
|
954
|
+
const high = index === changes.length ? timeline.toNs : changes[index];
|
|
955
|
+
const first = ceilDivide(low + offset, day) + 2n;
|
|
956
|
+
const last = floorDivide(high - 1n + offset, day) - 3n;
|
|
957
|
+
const insideFirst = ceilDivide(range.start + offset, day);
|
|
958
|
+
const insideLast = floorDivide(range.end + offset, day) - 1n;
|
|
959
|
+
const firstDay = first > insideFirst ? first : insideFirst;
|
|
960
|
+
const lastDay = last < insideLast ? last : insideLast;
|
|
961
|
+
if (firstDay <= lastDay) {
|
|
962
|
+
blocks.push({
|
|
963
|
+
firstDay: Number(firstDay),
|
|
964
|
+
lastDay: Number(lastDay),
|
|
965
|
+
startNs: firstDay * day - offset,
|
|
966
|
+
endNs: (lastDay + 1n) * day - offset,
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
return blocks;
|
|
971
|
+
}
|
|
972
|
+
/** The open time each date adds to the plain week, indexed by ISO weekday (index 0 is unused). */
|
|
973
|
+
function plainWeekCoverage(schedule) {
|
|
974
|
+
const plain = [0n];
|
|
975
|
+
for (let weekday = 1; weekday <= ISO_WEEKDAYS; weekday++) {
|
|
976
|
+
plain.push(dayCoverage(schedule.weekly[weekday === 1 ? ISO_WEEKDAYS : weekday - 1], schedule.weekly[weekday]));
|
|
977
|
+
}
|
|
978
|
+
return plain;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* What the holiday and override dates of a quiet block change from the plain week. A date differs
|
|
982
|
+
* from it when it or the date before it is a holiday or override.
|
|
983
|
+
*/
|
|
984
|
+
function specialDayCorrection(schedule, block, plain) {
|
|
985
|
+
const { specials } = schedule;
|
|
986
|
+
let total = 0n;
|
|
987
|
+
let handled = block.firstDay - 1;
|
|
988
|
+
for (let index = lowerBound(specials, block.firstDay - 1); index < specials.length && specials[index] <= block.lastDay; index++) {
|
|
989
|
+
for (const day of [specials[index], specials[index] + 1]) {
|
|
990
|
+
if (day > handled && day >= block.firstDay && day <= block.lastDay) {
|
|
991
|
+
total +=
|
|
992
|
+
dayCoverage(windowsOnDay(schedule, day - 1), windowsOnDay(schedule, day)) - plain[isoWeekdayOf(day)];
|
|
993
|
+
handled = day;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
return total;
|
|
998
|
+
}
|
|
999
|
+
/** Open time over the dates of a quiet block, from the weekly pattern and the special days. */
|
|
1000
|
+
function quietBlockOpenTime(schedule, block) {
|
|
1001
|
+
const plain = plainWeekCoverage(schedule);
|
|
1002
|
+
const dates = block.lastDay - block.firstDay + 1;
|
|
1003
|
+
const leftover = dates % ISO_WEEKDAYS;
|
|
1004
|
+
let week = 0n;
|
|
1005
|
+
for (let weekday = 1; weekday <= ISO_WEEKDAYS; weekday++) {
|
|
1006
|
+
week += plain[weekday];
|
|
1007
|
+
}
|
|
1008
|
+
let total = week * BigInt(Math.floor(dates / ISO_WEEKDAYS));
|
|
1009
|
+
for (let offset = 0; offset < leftover; offset++) {
|
|
1010
|
+
total += plain[isoWeekdayOf(block.firstDay + offset)];
|
|
1011
|
+
}
|
|
1012
|
+
return total + specialDayCorrection(schedule, block, plain);
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Open time in `[start, end)` by walking its dates, or `null` as `scheduleRunsWithin` is.
|
|
1016
|
+
* `timeline` is one a caller already built for the pieces of a range.
|
|
1017
|
+
*/
|
|
1018
|
+
function walkedOpenTime(schedule, start, end, disambiguation, timeline) {
|
|
1019
|
+
const runs = walkedRunsWithin(schedule, { start, end, startText: "", endText: "" }, disambiguation, timeline);
|
|
1020
|
+
return runs === null
|
|
1021
|
+
? null
|
|
1022
|
+
: runs.reduce((total, run) => total + (run.end - run.start), 0n);
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Open time in `[range.start, range.end)`, in nanoseconds; `null` exactly when
|
|
1026
|
+
* `scheduleRunsWithin` would be.
|
|
1027
|
+
*
|
|
1028
|
+
* Open time is additive over disjoint half-open pieces. Whole day buckets inside a stretch of
|
|
1029
|
+
* constant offset are summed in closed form (whole weeks of the weekly pattern, plus a correction
|
|
1030
|
+
* for each holiday and override); the pieces between them, the range's ends and the dates near an
|
|
1031
|
+
* offset change, are walked.
|
|
1032
|
+
*/
|
|
1033
|
+
export function openTimeWithin(schedule, range, disambiguation) {
|
|
1034
|
+
if (spansTooManyDates(schedule, range)) {
|
|
1035
|
+
return null;
|
|
1036
|
+
}
|
|
1037
|
+
let total = 0n;
|
|
1038
|
+
let cursor = range.start;
|
|
1039
|
+
let timeline;
|
|
1040
|
+
if (!walkNearsLimits(range.start)) {
|
|
1041
|
+
timeline = offsetTimeline(schedule.frame, range.start - 12n * NANOSECONDS_PER_DAY, range.end + 6n * NANOSECONDS_PER_DAY);
|
|
1042
|
+
for (const block of quietBlocks(timeline, range)) {
|
|
1043
|
+
const piece = walkedOpenTime(schedule, cursor, block.startNs, disambiguation, timeline);
|
|
1044
|
+
if (piece === null) {
|
|
1045
|
+
return null;
|
|
1046
|
+
}
|
|
1047
|
+
total += piece + quietBlockOpenTime(schedule, block);
|
|
1048
|
+
cursor = block.endNs;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
const last = walkedOpenTime(schedule, cursor, range.end, disambiguation, timeline);
|
|
1052
|
+
return last === null ? null : total + last;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Where `instantAfterOpenTime` can start walking: the first instant of the latest local date
|
|
1056
|
+
* whose start still has less than `amountNs` of open time before it, and the open time left after
|
|
1057
|
+
* that. A date that starts at or before `fromNs` (a fall-back repeats local midnight) starts at
|
|
1058
|
+
* `fromNs` instead, with nothing counted before it: counting from an earlier start would add open
|
|
1059
|
+
* time that precedes `fromNs`. Equal by additivity: the answer `X` has
|
|
1060
|
+
* `open[fromNs, X) = amountNs`, so it lies after that start. `undefined` when no date qualifies, when the walk could near Temporal's limits, or
|
|
1061
|
+
* when `openTimeWithin` is `null` (a window refused under `"reject"`): the walk then starts at
|
|
1062
|
+
* `fromNs`.
|
|
1063
|
+
*/
|
|
1064
|
+
function jumpOverWholeDays(schedule, fromNs, amountNs, horizonNs, disambiguation) {
|
|
1065
|
+
if (walkNearsLimits(fromNs)) {
|
|
1066
|
+
return undefined;
|
|
1067
|
+
}
|
|
1068
|
+
const timeline = offsetTimeline(schedule.frame, fromNs - 6n * NANOSECONDS_PER_DAY, fromNs + 14n * NANOSECONDS_PER_DAY);
|
|
1069
|
+
const firstDay = localDayOf(timeline, fromNs);
|
|
1070
|
+
const lastDay = localDayOf(timeline, horizonNs);
|
|
1071
|
+
// The open time before the start of `day`: below `amountNs`, or not (`undefined`: `null`).
|
|
1072
|
+
const before = (day) => {
|
|
1073
|
+
ensureTimeline(timeline, BigInt(day + 6) * NANOSECONDS_PER_DAY);
|
|
1074
|
+
const dayStart = startOfDayNs(timeline, day);
|
|
1075
|
+
const startNs = dayStart > fromNs ? dayStart : fromNs;
|
|
1076
|
+
const open = openTimeWithin(schedule, { start: fromNs, end: startNs, startText: "", endText: "" }, disambiguation);
|
|
1077
|
+
return open === null ? undefined : [startNs, open];
|
|
1078
|
+
};
|
|
1079
|
+
const found = latestDayBelow(firstDay, lastDay, amountNs, before);
|
|
1080
|
+
if (found === undefined) {
|
|
1081
|
+
return undefined;
|
|
1082
|
+
}
|
|
1083
|
+
return { startNs: found.startNs, remaining: amountNs - found.open };
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* The latest date in `(firstDay, lastDay]` whose probe reads less than `amountNs`: gallop away
|
|
1087
|
+
* from `firstDay`, then bisect between the last date below and the first not. `undefined` when
|
|
1088
|
+
* there is none or a probe is `undefined`.
|
|
1089
|
+
*/
|
|
1090
|
+
function latestDayBelow(firstDay, lastDay, amountNs, before) {
|
|
1091
|
+
let good;
|
|
1092
|
+
let bad = lastDay + 1;
|
|
1093
|
+
for (let step = 1; firstDay + step <= lastDay; step *= 2) {
|
|
1094
|
+
const probed = before(firstDay + step);
|
|
1095
|
+
if (probed === undefined) {
|
|
1096
|
+
return undefined;
|
|
1097
|
+
}
|
|
1098
|
+
if (probed[1] >= amountNs) {
|
|
1099
|
+
bad = firstDay + step;
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
good = { day: firstDay + step, startNs: probed[0], open: probed[1] };
|
|
1103
|
+
}
|
|
1104
|
+
while (good !== undefined && bad - good.day > 1) {
|
|
1105
|
+
const middle = good.day + Math.floor((bad - good.day) / 2);
|
|
1106
|
+
const probed = before(middle);
|
|
1107
|
+
if (probed === undefined) {
|
|
1108
|
+
return undefined;
|
|
1109
|
+
}
|
|
1110
|
+
if (probed[1] >= amountNs) {
|
|
1111
|
+
bad = middle;
|
|
1112
|
+
}
|
|
1113
|
+
else {
|
|
1114
|
+
good = { day: middle, startNs: probed[0], open: probed[1] };
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return good;
|
|
1118
|
+
}
|