@northguild/gmt 1.18.0 → 1.19.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/calculate/bucketRange.d.ts +10 -2
- package/dist/calendar/calculate/bucketRange.js +18 -61
- package/dist/calendar/calculate/floorToZone.d.ts +10 -2
- package/dist/calendar/calculate/floorToZone.js +15 -7
- package/dist/calendar/hours/addOperatingTime.d.ts +6 -0
- package/dist/calendar/hours/addOperatingTime.js +7 -1
- package/dist/calendar/hours/isOpenAt.d.ts +6 -0
- package/dist/calendar/hours/isOpenAt.js +6 -0
- package/dist/calendar/hours/nextCloseAt.d.ts +6 -0
- package/dist/calendar/hours/nextCloseAt.js +7 -1
- package/dist/calendar/hours/nextOpenAt.d.ts +6 -0
- package/dist/calendar/hours/nextOpenAt.js +7 -1
- package/dist/calendar/hours/operatingIntervals.d.ts +5 -0
- package/dist/calendar/hours/operatingIntervals.js +5 -0
- package/dist/calendar/hours/operatingTimeBetween.d.ts +5 -0
- package/dist/calendar/hours/operatingTimeBetween.js +5 -0
- package/dist/calendar/hours/recurringWindows.d.ts +8 -1
- package/dist/calendar/hours/recurringWindows.js +12 -4
- package/dist/duration/calculate/durationFromUnits.d.ts +47 -0
- package/dist/duration/calculate/durationFromUnits.js +67 -0
- package/dist/duration/calculate/getDurationUnit.d.ts +2 -2
- package/dist/duration/calculate/getDurationUnit.js +2 -2
- 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 +1 -1
- package/dist/duration/calculate/{durationAs.d.ts → totalDuration.d.ts} +25 -19
- package/dist/duration/calculate/{durationAs.js → totalDuration.js} +25 -19
- package/dist/duration/calculate/totalUnits.d.ts +49 -0
- package/dist/duration/calculate/totalUnits.js +73 -0
- package/dist/duration/compare/compareDurations.d.ts +1 -1
- package/dist/duration/compare/compareDurations.js +1 -1
- package/dist/duty/calculate/dutyDayFor.d.ts +38 -0
- package/dist/duty/calculate/dutyDayFor.js +71 -0
- package/dist/duty/calculate/dutyTotals.d.ts +24 -0
- package/dist/duty/calculate/dutyTotals.js +41 -0
- package/dist/duty/calculate/dutyViolations.d.ts +74 -0
- package/dist/duty/calculate/dutyViolations.js +65 -0
- package/dist/duty/calculate/evaluateDutyLog.d.ts +77 -0
- package/dist/duty/calculate/evaluateDutyLog.js +75 -0
- package/dist/duty/calculate/index.d.ts +7 -0
- package/dist/duty/calculate/index.js +7 -0
- package/dist/duty/calculate/longestRun.d.ts +28 -0
- package/dist/duty/calculate/longestRun.js +54 -0
- package/dist/duty/calculate/qualifyingRestPairs.d.ts +37 -0
- package/dist/duty/calculate/qualifyingRestPairs.js +58 -0
- package/dist/duty/calculate/qualifyingRests.d.ts +27 -0
- package/dist/duty/calculate/qualifyingRests.js +49 -0
- package/dist/duty/index.d.ts +3 -0
- package/dist/duty/index.js +4 -0
- package/dist/duty/validate/index.d.ts +1 -0
- package/dist/duty/validate/index.js +1 -0
- package/dist/duty/validate/isValidDutyLog.d.ts +24 -0
- package/dist/duty/validate/isValidDutyLog.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/instant/convert/classifyLocal.d.ts +5 -1
- package/dist/instant/convert/classifyLocal.js +16 -6
- package/dist/instant/convert/fromOffsetInstant.d.ts +4 -0
- package/dist/instant/convert/fromOffsetInstant.js +6 -1
- package/dist/instant/convert/resolveLocal.d.ts +7 -2
- package/dist/instant/convert/resolveLocal.js +16 -8
- package/dist/instant/convert/toOffsetInstant.d.ts +12 -8
- package/dist/instant/convert/toOffsetInstant.js +19 -11
- package/dist/instant/index.d.ts +1 -0
- package/dist/instant/index.js +1 -0
- 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/chargeableDays.d.ts +6 -0
- package/dist/intermodal/calculate/chargeableDays.js +12 -4
- package/dist/intermodal/calculate/freeTimeExpiry.d.ts +7 -0
- package/dist/intermodal/calculate/freeTimeExpiry.js +15 -4
- 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 +3 -0
- package/dist/intermodal/index.js +3 -0
- 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/businessCalendar.js +4 -9
- package/dist/internal/dutyEngine.d.ts +125 -0
- package/dist/internal/dutyEngine.js +1746 -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 +369 -0
- package/dist/internal/dutyRules.d.ts +197 -0
- package/dist/internal/dutyRules.js +484 -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 +3 -1
- package/dist/internal/englishCalendarNames.js +3 -1
- package/dist/internal/freeTimeLedger.d.ts +5 -0
- package/dist/internal/freeTimeLedger.js +11 -2
- package/dist/internal/index.d.ts +5 -2
- package/dist/internal/index.js +9 -2
- 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/isoYearString.d.ts +21 -0
- package/dist/internal/isoYearString.js +27 -0
- package/dist/internal/maxPieces.js +2 -1
- package/dist/internal/normalizeTimeZone.d.ts +4 -1
- package/dist/internal/normalizeTimeZone.js +4 -1
- package/dist/internal/operatingSchedule.d.ts +13 -4
- package/dist/internal/operatingSchedule.js +146 -58
- package/dist/internal/patternToken.d.ts +10 -3
- package/dist/internal/patternToken.js +31 -12
- 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/resolveRelativeUnit.d.ts +1 -1
- package/dist/internal/resolveRelativeUnit.js +1 -1
- package/dist/internal/resolveUnixIntervalPair.d.ts +8 -2
- package/dist/internal/resolveUnixIntervalPair.js +11 -7
- package/dist/internal/startOrEndOfUnix.d.ts +2 -1
- package/dist/internal/startOrEndOfUnix.js +9 -6
- package/dist/internal/twoDigitYear.d.ts +19 -0
- package/dist/internal/twoDigitYear.js +22 -0
- package/dist/internal/unixEpochValue.js +3 -2
- package/dist/internal/unixWallClock.d.ts +24 -0
- package/dist/internal/unixWallClock.js +35 -0
- package/dist/internal/utcWallClock.d.ts +20 -0
- package/dist/internal/utcWallClock.js +32 -0
- 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/zonedNowUnitValue.d.ts +7 -4
- package/dist/internal/zonedNowUnitValue.js +8 -4
- package/dist/internal/zonedWallClockDifference.js +4 -4
- package/dist/internal/zonedWallClockOperations.d.ts +5 -2
- package/dist/internal/zonedWallClockOperations.js +7 -10
- package/dist/plain/calculate/addDate.js +4 -7
- package/dist/plain/calculate/addDateTime.js +4 -7
- package/dist/plain/calculate/addTime.js +4 -7
- package/dist/plain/calculate/endOfTime.d.ts +1 -1
- package/dist/plain/calculate/setDate.d.ts +20 -3
- package/dist/plain/calculate/setDate.js +27 -7
- package/dist/plain/calculate/setDateTime.d.ts +15 -3
- package/dist/plain/calculate/setDateTime.js +22 -7
- package/dist/plain/calculate/setTime.d.ts +13 -1
- package/dist/plain/calculate/setTime.js +21 -6
- package/dist/plain/calculate/startOfTime.d.ts +1 -1
- package/dist/plain/calculate/subtractDate.js +4 -7
- package/dist/plain/calculate/subtractDateTime.js +4 -7
- package/dist/plain/calculate/subtractTime.js +4 -7
- package/dist/plain/format/formatCalendar.js +2 -1
- package/dist/plain/format/formatRelativeDate.js +2 -1
- package/dist/plain/format/formatRelativeDateTime.js +2 -1
- package/dist/plain/format/formatRelativeTime.js +2 -1
- package/dist/plain/format/{formatSql.d.ts → formatSqlDateTime.d.ts} +7 -7
- package/dist/plain/format/{formatSql.js → formatSqlDateTime.js} +7 -7
- package/dist/plain/format/index.d.ts +1 -1
- package/dist/plain/format/index.js +1 -1
- package/dist/plain/get/getNowUnit.d.ts +2 -0
- package/dist/plain/get/getNowUnit.js +2 -0
- package/dist/plain/get/getYear.d.ts +2 -0
- package/dist/plain/get/getYear.js +4 -3
- package/dist/plain/interval/intervalXorAllDate.js +2 -2
- package/dist/plain/interval/intervalXorAllDateTime.js +2 -2
- package/dist/plain/interval/intervalXorAllTime.js +2 -2
- package/dist/plain/interval/mergeIntervalsDate.js +2 -2
- package/dist/plain/interval/mergeIntervalsDateTime.js +2 -2
- package/dist/plain/interval/mergeIntervalsTime.js +2 -2
- package/dist/plain/parse/index.d.ts +1 -1
- package/dist/plain/parse/index.js +1 -1
- package/dist/plain/parse/parseDateTimeWithPattern.d.ts +16 -3
- package/dist/plain/parse/parseDateTimeWithPattern.js +20 -5
- package/dist/plain/parse/parseDateWithPattern.d.ts +17 -3
- package/dist/plain/parse/parseDateWithPattern.js +21 -5
- package/dist/plain/parse/{parseSql.d.ts → parseSqlDateTime.d.ts} +8 -8
- package/dist/plain/parse/{parseSql.js → parseSqlDateTime.js} +8 -8
- package/dist/plain/parse/parseTimeWithPattern.js +1 -0
- package/dist/plain/parse/parseUnitFromDate.d.ts +3 -0
- package/dist/plain/parse/parseUnitFromDate.js +5 -1
- package/dist/plain/parse/parseUnitFromDateTime.d.ts +3 -0
- package/dist/plain/parse/parseUnitFromDateTime.js +5 -1
- package/dist/plain/parse/parseYearFromDate.d.ts +5 -2
- package/dist/plain/parse/parseYearFromDate.js +7 -3
- package/dist/plain/parse/parseYearFromDateTime.d.ts +4 -2
- package/dist/plain/parse/parseYearFromDateTime.js +6 -3
- package/dist/plain/validate/index.d.ts +1 -0
- package/dist/plain/validate/index.js +1 -0
- package/dist/plain/validate/isValidSqlDateTime.d.ts +33 -0
- package/dist/plain/validate/isValidSqlDateTime.js +36 -0
- package/dist/precision/convert/fromNanoseconds.d.ts +9 -3
- package/dist/precision/convert/fromNanoseconds.js +9 -3
- 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 +1 -0
- package/dist/regex/index.js +1 -0
- 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 +3 -2
- package/dist/regex/time-zone-like.js +3 -2
- package/dist/regex/utc-offset.d.ts +2 -1
- package/dist/regex/utc-offset.js +2 -1
- package/dist/transport/calculate/crossingTime.d.ts +6 -1
- package/dist/transport/calculate/crossingTime.js +6 -1
- package/dist/transport/calculate/cutoffAt.d.ts +6 -1
- package/dist/transport/calculate/cutoffAt.js +2 -0
- package/dist/transport/calculate/cutoffSchedule.d.ts +6 -1
- package/dist/transport/calculate/cutoffSchedule.js +2 -0
- package/dist/transport/calculate/dwellTime.d.ts +6 -1
- package/dist/transport/calculate/dwellTime.js +6 -1
- package/dist/transport/calculate/scheduleDelivery.d.ts +13 -5
- package/dist/transport/calculate/scheduleDelivery.js +6 -1
- package/dist/transport/convert/etaAtZone.d.ts +6 -1
- package/dist/transport/convert/etaAtZone.js +6 -1
- package/dist/types/business-calendar.d.ts +5 -4
- 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/free-time-options.d.ts +4 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/operating-schedule.d.ts +3 -2
- package/dist/types/two-digit-year.d.ts +23 -0
- package/dist/types/two-digit-year.js +0 -0
- 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 +10 -2
- package/dist/unix/calculate/diffUnix.js +11 -6
- package/dist/unix/calculate/diffUnixAsDuration.d.ts +10 -2
- 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 +11 -2
- package/dist/unix/calculate/endOfUnix.js +7 -0
- package/dist/unix/calculate/isBetweenUnix.d.ts +3 -2
- package/dist/unix/calculate/isBetweenUnix.js +3 -3
- package/dist/unix/calculate/roundUnix.d.ts +10 -2
- package/dist/unix/calculate/roundUnix.js +13 -6
- package/dist/unix/calculate/setUnix.d.ts +25 -5
- package/dist/unix/calculate/setUnix.js +33 -12
- package/dist/unix/calculate/startOfQuarterForUnix.d.ts +10 -2
- package/dist/unix/calculate/startOfQuarterForUnix.js +6 -0
- package/dist/unix/calculate/startOfUnix.d.ts +11 -2
- package/dist/unix/calculate/startOfUnix.js +7 -0
- package/dist/unix/calculate/subtractUnix.d.ts +10 -2
- package/dist/unix/calculate/subtractUnix.js +13 -11
- package/dist/unix/compare/areUnixEqualBy.d.ts +11 -2
- package/dist/unix/compare/areUnixEqualBy.js +7 -0
- 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 +5 -2
- package/dist/unix/convert/convertUnixToPlainTime.js +5 -4
- package/dist/unix/convert/convertUnixToZoned.d.ts +5 -1
- package/dist/unix/convert/convertUnixToZoned.js +5 -1
- package/dist/unix/format/formatCalendarUnix.d.ts +6 -2
- package/dist/unix/format/formatCalendarUnix.js +6 -1
- package/dist/unix/format/formatRelativeUnix.d.ts +11 -3
- package/dist/unix/format/formatRelativeUnix.js +13 -5
- package/dist/unix/format/formatUnix.d.ts +7 -2
- package/dist/unix/format/formatUnix.js +4 -0
- package/dist/unix/get/getUnixDay.d.ts +1 -3
- package/dist/unix/get/getUnixDay.js +5 -12
- package/dist/unix/get/getUnixHour.d.ts +1 -3
- package/dist/unix/get/getUnixHour.js +5 -12
- package/dist/unix/get/getUnixMicrosecond.d.ts +1 -3
- package/dist/unix/get/getUnixMicrosecond.js +4 -11
- package/dist/unix/get/getUnixMillisecond.d.ts +1 -3
- package/dist/unix/get/getUnixMillisecond.js +5 -12
- package/dist/unix/get/getUnixMinute.d.ts +1 -3
- package/dist/unix/get/getUnixMinute.js +5 -12
- package/dist/unix/get/getUnixMonth.d.ts +1 -3
- package/dist/unix/get/getUnixMonth.js +5 -12
- package/dist/unix/get/getUnixNanosecond.d.ts +1 -3
- package/dist/unix/get/getUnixNanosecond.js +4 -11
- package/dist/unix/get/getUnixNowUnit.d.ts +2 -0
- package/dist/unix/get/getUnixNowUnit.js +2 -0
- package/dist/unix/get/getUnixSecond.d.ts +1 -3
- package/dist/unix/get/getUnixSecond.js +5 -12
- package/dist/unix/get/getUnixYear.d.ts +3 -3
- package/dist/unix/get/getUnixYear.js +5 -12
- 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 +12 -7
- package/dist/unix/interval/intervalLengthUnix.d.ts +10 -2
- package/dist/unix/interval/intervalLengthUnix.js +6 -0
- package/dist/unix/interval/intervalOverlappingDaysUnix.d.ts +10 -2
- package/dist/unix/interval/intervalOverlappingDaysUnix.js +10 -5
- package/dist/unix/interval/splitIntervalByUnitUnix.d.ts +10 -2
- package/dist/unix/interval/splitIntervalByUnitUnix.js +12 -6
- 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 +9 -3
- 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 +4 -7
- package/dist/utc/calculate/setUtc.d.ts +16 -3
- package/dist/utc/calculate/setUtc.js +22 -8
- package/dist/utc/calculate/subtractUtc.js +4 -7
- package/dist/utc/convert/convertUtcToPlainDate.d.ts +8 -2
- package/dist/utc/convert/convertUtcToPlainDate.js +10 -7
- package/dist/utc/convert/convertUtcToPlainDateTime.d.ts +9 -2
- package/dist/utc/convert/convertUtcToPlainDateTime.js +12 -13
- package/dist/utc/convert/convertUtcToPlainTime.d.ts +5 -2
- package/dist/utc/convert/convertUtcToPlainTime.js +7 -6
- package/dist/utc/convert/convertUtcToZoned.d.ts +5 -1
- package/dist/utc/convert/convertUtcToZoned.js +5 -1
- package/dist/utc/format/formatCalendarUtc.d.ts +6 -2
- package/dist/utc/format/formatCalendarUtc.js +6 -1
- package/dist/utc/format/{formatHttp.d.ts → formatHttpDate.d.ts} +7 -7
- package/dist/utc/format/{formatHttp.js → formatHttpDate.js} +7 -7
- package/dist/utc/format/formatRelativeUtc.d.ts +11 -3
- package/dist/utc/format/formatRelativeUtc.js +13 -5
- package/dist/utc/format/formatUtc.d.ts +7 -2
- package/dist/utc/format/formatUtc.js +4 -0
- 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 +5 -12
- package/dist/utc/get/getUtcHour.d.ts +1 -3
- package/dist/utc/get/getUtcHour.js +5 -12
- package/dist/utc/get/getUtcMicrosecond.d.ts +1 -3
- package/dist/utc/get/getUtcMicrosecond.js +4 -11
- package/dist/utc/get/getUtcMillisecond.d.ts +1 -3
- package/dist/utc/get/getUtcMillisecond.js +5 -12
- package/dist/utc/get/getUtcMinute.d.ts +1 -3
- package/dist/utc/get/getUtcMinute.js +5 -12
- package/dist/utc/get/getUtcMonth.d.ts +1 -3
- package/dist/utc/get/getUtcMonth.js +5 -12
- package/dist/utc/get/getUtcNanosecond.d.ts +1 -3
- package/dist/utc/get/getUtcNanosecond.js +4 -11
- package/dist/utc/get/getUtcNow.d.ts +1 -3
- package/dist/utc/get/getUtcNow.js +2 -9
- package/dist/utc/get/getUtcNowUnit.d.ts +2 -0
- package/dist/utc/get/getUtcNowUnit.js +2 -0
- package/dist/utc/get/getUtcSecond.d.ts +1 -3
- package/dist/utc/get/getUtcSecond.js +5 -12
- package/dist/utc/get/getUtcYear.d.ts +3 -3
- package/dist/utc/get/getUtcYear.js +5 -12
- package/dist/utc/interval/intervalXorAllUtc.js +2 -2
- package/dist/utc/interval/mergeIntervalsUtc.js +2 -2
- package/dist/utc/parse/index.d.ts +1 -1
- package/dist/utc/parse/index.js +1 -1
- package/dist/utc/parse/parseDateFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseDateFromUtc.js +2 -2
- package/dist/utc/parse/parseDayFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseDayFromUtc.js +2 -2
- package/dist/utc/parse/parseDayOfWeekFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseDayOfWeekFromUtc.js +4 -4
- package/dist/utc/parse/parseHourFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseHourFromUtc.js +2 -2
- package/dist/utc/parse/{parseHttp.d.ts → parseHttpDate.d.ts} +12 -12
- package/dist/utc/parse/{parseHttp.js → parseHttpDate.js} +12 -12
- package/dist/utc/parse/parseMicrosecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMicrosecondFromUtc.js +2 -2
- package/dist/utc/parse/parseMillisecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMillisecondFromUtc.js +2 -2
- package/dist/utc/parse/parseMinuteFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMinuteFromUtc.js +2 -2
- package/dist/utc/parse/parseMonthFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseMonthFromUtc.js +2 -2
- package/dist/utc/parse/parseNanosecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseNanosecondFromUtc.js +2 -2
- package/dist/utc/parse/parseSecondFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseSecondFromUtc.js +2 -2
- package/dist/utc/parse/parseTimeFromUtc.d.ts +5 -2
- package/dist/utc/parse/parseTimeFromUtc.js +5 -4
- package/dist/utc/parse/parseUnitFromUtc.d.ts +10 -3
- package/dist/utc/parse/parseUnitFromUtc.js +11 -5
- package/dist/utc/parse/parseWeekFromUtc.d.ts +4 -2
- package/dist/utc/parse/parseWeekFromUtc.js +4 -4
- package/dist/utc/parse/parseYearFromUtc.d.ts +8 -4
- package/dist/utc/parse/parseYearFromUtc.js +8 -5
- 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 +4 -0
- package/dist/utc/validate/isValidUtcTimestamp.d.ts +43 -0
- package/dist/utc/validate/isValidUtcTimestamp.js +48 -0
- package/dist/zoned/calculate/addZoned.js +4 -7
- package/dist/zoned/calculate/setZoned.d.ts +19 -5
- package/dist/zoned/calculate/setZoned.js +26 -9
- package/dist/zoned/calculate/subtractZoned.js +4 -7
- package/dist/zoned/convert/convertPlainDateTimeToZoned.d.ts +4 -1
- package/dist/zoned/convert/convertPlainDateTimeToZoned.js +4 -1
- package/dist/zoned/convert/convertZonedToZoned.d.ts +5 -1
- package/dist/zoned/convert/convertZonedToZoned.js +5 -1
- package/dist/zoned/format/formatCalendarZoned.js +2 -1
- package/dist/zoned/format/formatRelativeZoned.js +2 -1
- package/dist/zoned/format/formatTimeZoneName.d.ts +5 -1
- package/dist/zoned/format/formatTimeZoneName.js +5 -1
- package/dist/zoned/get/getDstTransitions.d.ts +5 -3
- package/dist/zoned/get/getDstTransitions.js +12 -7
- package/dist/zoned/get/getSystemTimeZone.d.ts +3 -1
- package/dist/zoned/get/getSystemTimeZone.js +5 -2
- package/dist/zoned/get/getTimeZoneOffset.d.ts +10 -2
- package/dist/zoned/get/getTimeZoneOffset.js +18 -5
- package/dist/zoned/get/getZonedDay.d.ts +2 -1
- package/dist/zoned/get/getZonedDay.js +6 -7
- package/dist/zoned/get/getZonedDayOfWeek.d.ts +2 -1
- package/dist/zoned/get/getZonedDayOfWeek.js +6 -5
- package/dist/zoned/get/getZonedHour.d.ts +2 -1
- package/dist/zoned/get/getZonedHour.js +6 -7
- package/dist/zoned/get/getZonedMicrosecond.d.ts +2 -1
- package/dist/zoned/get/getZonedMicrosecond.js +6 -5
- package/dist/zoned/get/getZonedMillisecond.d.ts +2 -1
- package/dist/zoned/get/getZonedMillisecond.js +6 -7
- package/dist/zoned/get/getZonedMinute.d.ts +2 -1
- package/dist/zoned/get/getZonedMinute.js +6 -7
- package/dist/zoned/get/getZonedMonth.d.ts +2 -1
- package/dist/zoned/get/getZonedMonth.js +6 -7
- package/dist/zoned/get/getZonedNanosecond.d.ts +2 -1
- package/dist/zoned/get/getZonedNanosecond.js +6 -5
- package/dist/zoned/get/getZonedNow.d.ts +5 -1
- package/dist/zoned/get/getZonedNow.js +5 -1
- package/dist/zoned/get/getZonedNowUnit.d.ts +6 -3
- package/dist/zoned/get/getZonedNowUnit.js +10 -7
- package/dist/zoned/get/getZonedSecond.d.ts +2 -1
- package/dist/zoned/get/getZonedSecond.js +6 -7
- package/dist/zoned/get/getZonedToday.d.ts +2 -1
- package/dist/zoned/get/getZonedToday.js +6 -5
- package/dist/zoned/get/getZonedWeekOfYear.d.ts +2 -1
- package/dist/zoned/get/getZonedWeekOfYear.js +6 -5
- package/dist/zoned/get/getZonedYear.d.ts +4 -1
- package/dist/zoned/get/getZonedYear.js +9 -7
- package/dist/zoned/interval/intervalXorAllZoned.js +2 -2
- package/dist/zoned/interval/mergeIntervalsZoned.js +2 -2
- package/dist/zoned/parse/parseUnitFromZoned.d.ts +4 -1
- 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 +4 -2
- package/dist/zoned/validate/hasDaylightSaving.js +13 -7
- package/dist/zoned/validate/index.d.ts +2 -0
- package/dist/zoned/validate/index.js +2 -0
- 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 +5 -1
- package/dist/zoned/validate/isValidTimeZone.js +6 -2
- package/package.json +50 -1
- package/skills/gmt-arithmetic/SKILL.md +99 -12
- package/skills/gmt-basics/SKILL.md +57 -15
- package/skills/gmt-integration/SKILL.md +24 -9
- package/skills/gmt-timezone/SKILL.md +134 -29
- 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
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* 2016 on, although its clocks went forward in March 2016.
|
|
18
18
|
* - Read from the runtime's time zone data, so the answer can change when that data does.
|
|
19
19
|
* - Returns false for an invalid timeZone, an invalid `at`, an options argument that is not an
|
|
20
|
-
* object, and a fixed offset.
|
|
20
|
+
* object, and a fixed UTC offset, with or without seconds (`"+05:30"`, `"-00:44:30"`).
|
|
21
21
|
*
|
|
22
|
-
* @param timeZone
|
|
22
|
+
* @param timeZone IANA name or UTC offset: a time zone identifier (`+05:30`, `+0530`, `-08`) or a
|
|
23
|
+
* stored offset (`±HH:MM[:SS]`, what `getTimeZoneOffset` returns)
|
|
23
24
|
* @param options optional setting for the reference instant
|
|
24
25
|
* @returns boolean indicating whether the timeZone observes DST, or false on invalid input
|
|
25
26
|
*
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
* @example hasDaylightSaving("+05:00", { at: "2024-01-15T12:00:00Z" }) // false
|
|
35
36
|
* @example hasDaylightSaving("Invalid/Zone", { at: "2024-01-15T12:00:00Z" }) // false
|
|
36
37
|
* @example hasDaylightSaving("America/New_York", { at: "2024-01-15" }) // false (not an instant)
|
|
38
|
+
* @example hasDaylightSaving("-00:44:30", { at: "1970-01-01T12:00:00Z" }) // false (a fixed offset)
|
|
37
39
|
*/
|
|
38
40
|
export declare function hasDaylightSaving(timeZone: string, options?: {
|
|
39
41
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import { isOptionsArgument, observesDaylightTime, parseInstantNanoseconds, } from "../../internal/index.js";
|
|
3
|
-
import { isValidTimeZone } from "./isValidTimeZone.js";
|
|
2
|
+
import { isOptionsArgument, observesDaylightTime, parseInstantNanoseconds, zoneFrame, } from "../../internal/index.js";
|
|
4
3
|
/**
|
|
5
4
|
* Check whether a timeZone observes daylight saving time at a reference instant.
|
|
6
5
|
*
|
|
@@ -20,9 +19,10 @@ import { isValidTimeZone } from "./isValidTimeZone.js";
|
|
|
20
19
|
* 2016 on, although its clocks went forward in March 2016.
|
|
21
20
|
* - Read from the runtime's time zone data, so the answer can change when that data does.
|
|
22
21
|
* - Returns false for an invalid timeZone, an invalid `at`, an options argument that is not an
|
|
23
|
-
* object, and a fixed offset.
|
|
22
|
+
* object, and a fixed UTC offset, with or without seconds (`"+05:30"`, `"-00:44:30"`).
|
|
24
23
|
*
|
|
25
|
-
* @param timeZone
|
|
24
|
+
* @param timeZone IANA name or UTC offset: a time zone identifier (`+05:30`, `+0530`, `-08`) or a
|
|
25
|
+
* stored offset (`±HH:MM[:SS]`, what `getTimeZoneOffset` returns)
|
|
26
26
|
* @param options optional setting for the reference instant
|
|
27
27
|
* @returns boolean indicating whether the timeZone observes DST, or false on invalid input
|
|
28
28
|
*
|
|
@@ -37,21 +37,27 @@ import { isValidTimeZone } from "./isValidTimeZone.js";
|
|
|
37
37
|
* @example hasDaylightSaving("+05:00", { at: "2024-01-15T12:00:00Z" }) // false
|
|
38
38
|
* @example hasDaylightSaving("Invalid/Zone", { at: "2024-01-15T12:00:00Z" }) // false
|
|
39
39
|
* @example hasDaylightSaving("America/New_York", { at: "2024-01-15" }) // false (not an instant)
|
|
40
|
+
* @example hasDaylightSaving("-00:44:30", { at: "1970-01-01T12:00:00Z" }) // false (a fixed offset)
|
|
40
41
|
*/
|
|
41
42
|
export function hasDaylightSaving(timeZone, options) {
|
|
42
|
-
|
|
43
|
+
const frame = zoneFrame(timeZone);
|
|
44
|
+
// A stored offset with seconds is a fixed offset: it observes no daylight time, as "-00:45"
|
|
45
|
+
// observes none.
|
|
46
|
+
if (frame === null ||
|
|
47
|
+
frame.shiftNanoseconds !== 0n ||
|
|
48
|
+
!isOptionsArgument(options)) {
|
|
43
49
|
return false;
|
|
44
50
|
}
|
|
45
51
|
try {
|
|
46
52
|
const at = options?.at;
|
|
47
53
|
if (at === undefined) {
|
|
48
|
-
return observesDaylightTime(Temporal.Now.zonedDateTimeISO(timeZone));
|
|
54
|
+
return observesDaylightTime(Temporal.Now.zonedDateTimeISO(frame.timeZone));
|
|
49
55
|
}
|
|
50
56
|
const epochNanoseconds = parseInstantNanoseconds(at);
|
|
51
57
|
if (epochNanoseconds === null) {
|
|
52
58
|
return false;
|
|
53
59
|
}
|
|
54
|
-
return observesDaylightTime(Temporal.Instant.fromEpochNanoseconds(epochNanoseconds).toZonedDateTimeISO(timeZone));
|
|
60
|
+
return observesDaylightTime(Temporal.Instant.fromEpochNanoseconds(epochNanoseconds).toZonedDateTimeISO(frame.timeZone));
|
|
55
61
|
}
|
|
56
62
|
catch {
|
|
57
63
|
return false;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./hasDaylightSaving.js";
|
|
2
2
|
export * from "./isValidCalendarZonedDateTime.js";
|
|
3
|
+
export * from "./isValidRfc2822DateTime.js";
|
|
4
|
+
export * from "./isValidRfc3339DateTime.js";
|
|
3
5
|
export * from "./isValidTimeZone.js";
|
|
4
6
|
export * from "./isValidZonedDateTime.js";
|
|
5
7
|
export * from "./isValidZonedRange.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./hasDaylightSaving.js";
|
|
2
2
|
export * from "./isValidCalendarZonedDateTime.js";
|
|
3
|
+
export * from "./isValidRfc2822DateTime.js";
|
|
4
|
+
export * from "./isValidRfc3339DateTime.js";
|
|
3
5
|
export * from "./isValidTimeZone.js";
|
|
4
6
|
export * from "./isValidZonedDateTime.js";
|
|
5
7
|
export * from "./isValidZonedRange.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true when `value` is a real RFC 5322 (RFC 2822) date-time: the date an email `Date:`
|
|
3
|
+
* header carries, such as `Fri, 15 Mar 2024 14:30:00 -0400`.
|
|
4
|
+
*
|
|
5
|
+
* - True exactly when `parseRfc2822` returns a zoned string for the same value: the validator
|
|
6
|
+
* calls the parser, so the two cannot disagree.
|
|
7
|
+
* - **Reads what a conformant receiver must**, which is more than the strict `rfc2822DateTime`
|
|
8
|
+
* pattern matches: RFC 5322 §3.3 folding white space, comments, names in any case and a year of
|
|
9
|
+
* more than four digits, and the §4 obsolete syntax (2- and 3-digit years, military and other
|
|
10
|
+
* alphabetic zones). `parseRfc2822` lists each form.
|
|
11
|
+
* - Checks the calendar as well as the shape. The pattern matches a day that does not exist:
|
|
12
|
+
* `31 Feb`, `29 Feb 2023` and `31 Jun` are false here.
|
|
13
|
+
* - **The day-of-week must match the date.** RFC 5322 §3.3: "the day-of-week (if included) MUST be
|
|
14
|
+
* the day implied by the date". The pattern does not check it.
|
|
15
|
+
* - False for an hour above 23, a minute above 59, zone minutes above 59 and an offset of 24
|
|
16
|
+
* hours or more, all of which the pattern matches. False for a second of 60: GMT rejects leap
|
|
17
|
+
* seconds.
|
|
18
|
+
* - False for a non-string. Read the value with `parseRfc2822`; write one with `formatRfc2822`.
|
|
19
|
+
*
|
|
20
|
+
* @param value candidate RFC 5322 date-time string
|
|
21
|
+
* @returns boolean indicating validity
|
|
22
|
+
*
|
|
23
|
+
* @example isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00 -0400") // true
|
|
24
|
+
* @example isValidRfc2822DateTime("5 Jan 2024 09:00:00 GMT") // true (no day-of-week, 1-digit day)
|
|
25
|
+
* @example isValidRfc2822DateTime("fri,15 Mar 24 14:30 -0400 (EDT)") // true (obsolete 2-digit year, comment; the rfc2822DateTime pattern does not match it)
|
|
26
|
+
* @example isValidRfc2822DateTime("Sat, 15 Mar 2024 14:30:00 -0400") // false (15 Mar 2024 was a Friday; the rfc2822DateTime pattern matches it)
|
|
27
|
+
* @example isValidRfc2822DateTime("Wed, 29 Feb 2023 14:30:00 -0400") // false (2023 has no 29 February; the rfc2822DateTime pattern matches it)
|
|
28
|
+
* @example isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00 -0460") // false (zone minutes above 59; the rfc2822DateTime pattern matches it)
|
|
29
|
+
* @example isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00") // false (no zone)
|
|
30
|
+
* @example isValidRfc2822DateTime("not a date") // false
|
|
31
|
+
*/
|
|
32
|
+
export declare function isValidRfc2822DateTime(value: string): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { parseRfc2822 } from "../parse/parseRfc2822.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is a real RFC 5322 (RFC 2822) date-time: the date an email `Date:`
|
|
4
|
+
* header carries, such as `Fri, 15 Mar 2024 14:30:00 -0400`.
|
|
5
|
+
*
|
|
6
|
+
* - True exactly when `parseRfc2822` returns a zoned string for the same value: the validator
|
|
7
|
+
* calls the parser, so the two cannot disagree.
|
|
8
|
+
* - **Reads what a conformant receiver must**, which is more than the strict `rfc2822DateTime`
|
|
9
|
+
* pattern matches: RFC 5322 §3.3 folding white space, comments, names in any case and a year of
|
|
10
|
+
* more than four digits, and the §4 obsolete syntax (2- and 3-digit years, military and other
|
|
11
|
+
* alphabetic zones). `parseRfc2822` lists each form.
|
|
12
|
+
* - Checks the calendar as well as the shape. The pattern matches a day that does not exist:
|
|
13
|
+
* `31 Feb`, `29 Feb 2023` and `31 Jun` are false here.
|
|
14
|
+
* - **The day-of-week must match the date.** RFC 5322 §3.3: "the day-of-week (if included) MUST be
|
|
15
|
+
* the day implied by the date". The pattern does not check it.
|
|
16
|
+
* - False for an hour above 23, a minute above 59, zone minutes above 59 and an offset of 24
|
|
17
|
+
* hours or more, all of which the pattern matches. False for a second of 60: GMT rejects leap
|
|
18
|
+
* seconds.
|
|
19
|
+
* - False for a non-string. Read the value with `parseRfc2822`; write one with `formatRfc2822`.
|
|
20
|
+
*
|
|
21
|
+
* @param value candidate RFC 5322 date-time string
|
|
22
|
+
* @returns boolean indicating validity
|
|
23
|
+
*
|
|
24
|
+
* @example isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00 -0400") // true
|
|
25
|
+
* @example isValidRfc2822DateTime("5 Jan 2024 09:00:00 GMT") // true (no day-of-week, 1-digit day)
|
|
26
|
+
* @example isValidRfc2822DateTime("fri,15 Mar 24 14:30 -0400 (EDT)") // true (obsolete 2-digit year, comment; the rfc2822DateTime pattern does not match it)
|
|
27
|
+
* @example isValidRfc2822DateTime("Sat, 15 Mar 2024 14:30:00 -0400") // false (15 Mar 2024 was a Friday; the rfc2822DateTime pattern matches it)
|
|
28
|
+
* @example isValidRfc2822DateTime("Wed, 29 Feb 2023 14:30:00 -0400") // false (2023 has no 29 February; the rfc2822DateTime pattern matches it)
|
|
29
|
+
* @example isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00 -0460") // false (zone minutes above 59; the rfc2822DateTime pattern matches it)
|
|
30
|
+
* @example isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00") // false (no zone)
|
|
31
|
+
* @example isValidRfc2822DateTime("not a date") // false
|
|
32
|
+
*/
|
|
33
|
+
export function isValidRfc2822DateTime(value) {
|
|
34
|
+
return parseRfc2822(value) !== "";
|
|
35
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true when `value` is a real RFC 3339 date-time: an ISO 8601 date and time that always
|
|
3
|
+
* states its UTC offset, as `Z` or `±HH:MM` (RFC 3339 §5.6).
|
|
4
|
+
*
|
|
5
|
+
* - True exactly when `parseRfc3339` returns a zoned string for the same value: the validator
|
|
6
|
+
* calls the parser, so the two cannot disagree.
|
|
7
|
+
* - Checks the calendar as well as the shape. The `rfc3339DateTime` pattern proves the shape
|
|
8
|
+
* alone, so it matches a day that does not exist: 29 February in a common year and 31 June are
|
|
9
|
+
* false here.
|
|
10
|
+
* - Accepts `T`, `t` or a single space between the date and the time, `Z` or `z`, a numeric
|
|
11
|
+
* offset from `-23:59` to `+23:59`, and up to nine fraction digits.
|
|
12
|
+
* - False for a leap second (`:60`), although §5.6 `time-second` admits it: GMT rejects leap
|
|
13
|
+
* seconds because Temporal would read one as `:59`.
|
|
14
|
+
* - False for GMT's own zoned strings, which carry a bracketed zone (`...+00:00[UTC]`): that
|
|
15
|
+
* annotation is not RFC 3339. Check those with `isValidZonedDateTime`.
|
|
16
|
+
* - False for a non-string. Read the value with `parseRfc3339`; write one with `formatRfc3339`.
|
|
17
|
+
*
|
|
18
|
+
* @param value candidate RFC 3339 date-time string
|
|
19
|
+
* @returns boolean indicating validity
|
|
20
|
+
*
|
|
21
|
+
* @example isValidRfc3339DateTime("2024-03-15T14:30:00-04:00") // true
|
|
22
|
+
* @example isValidRfc3339DateTime("2024-03-15t14:30:00z") // true (lower-case t and z)
|
|
23
|
+
* @example isValidRfc3339DateTime("2024-03-15 14:30:00.5Z") // true (space separator, fraction)
|
|
24
|
+
* @example isValidRfc3339DateTime("2023-02-29T10:00:00Z") // false (2023 has no 29 February; the rfc3339DateTime pattern matches it)
|
|
25
|
+
* @example isValidRfc3339DateTime("2024-06-31T10:00:00Z") // false (June has 30 days; the rfc3339DateTime pattern matches it)
|
|
26
|
+
* @example isValidRfc3339DateTime("2016-12-31T23:59:60Z") // false (leap second)
|
|
27
|
+
* @example isValidRfc3339DateTime("2024-03-15T14:30:00") // false (no offset)
|
|
28
|
+
* @example isValidRfc3339DateTime("2024-03-15T14:30:00+00:00[UTC]") // false (bracketed zone: use isValidZonedDateTime)
|
|
29
|
+
* @example isValidRfc3339DateTime("not a date") // false
|
|
30
|
+
*/
|
|
31
|
+
export declare function isValidRfc3339DateTime(value: string): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { parseRfc3339 } from "../parse/parseRfc3339.js";
|
|
2
|
+
/**
|
|
3
|
+
* Return true when `value` is a real RFC 3339 date-time: an ISO 8601 date and time that always
|
|
4
|
+
* states its UTC offset, as `Z` or `±HH:MM` (RFC 3339 §5.6).
|
|
5
|
+
*
|
|
6
|
+
* - True exactly when `parseRfc3339` returns a zoned string for the same value: the validator
|
|
7
|
+
* calls the parser, so the two cannot disagree.
|
|
8
|
+
* - Checks the calendar as well as the shape. The `rfc3339DateTime` pattern proves the shape
|
|
9
|
+
* alone, so it matches a day that does not exist: 29 February in a common year and 31 June are
|
|
10
|
+
* false here.
|
|
11
|
+
* - Accepts `T`, `t` or a single space between the date and the time, `Z` or `z`, a numeric
|
|
12
|
+
* offset from `-23:59` to `+23:59`, and up to nine fraction digits.
|
|
13
|
+
* - False for a leap second (`:60`), although §5.6 `time-second` admits it: GMT rejects leap
|
|
14
|
+
* seconds because Temporal would read one as `:59`.
|
|
15
|
+
* - False for GMT's own zoned strings, which carry a bracketed zone (`...+00:00[UTC]`): that
|
|
16
|
+
* annotation is not RFC 3339. Check those with `isValidZonedDateTime`.
|
|
17
|
+
* - False for a non-string. Read the value with `parseRfc3339`; write one with `formatRfc3339`.
|
|
18
|
+
*
|
|
19
|
+
* @param value candidate RFC 3339 date-time string
|
|
20
|
+
* @returns boolean indicating validity
|
|
21
|
+
*
|
|
22
|
+
* @example isValidRfc3339DateTime("2024-03-15T14:30:00-04:00") // true
|
|
23
|
+
* @example isValidRfc3339DateTime("2024-03-15t14:30:00z") // true (lower-case t and z)
|
|
24
|
+
* @example isValidRfc3339DateTime("2024-03-15 14:30:00.5Z") // true (space separator, fraction)
|
|
25
|
+
* @example isValidRfc3339DateTime("2023-02-29T10:00:00Z") // false (2023 has no 29 February; the rfc3339DateTime pattern matches it)
|
|
26
|
+
* @example isValidRfc3339DateTime("2024-06-31T10:00:00Z") // false (June has 30 days; the rfc3339DateTime pattern matches it)
|
|
27
|
+
* @example isValidRfc3339DateTime("2016-12-31T23:59:60Z") // false (leap second)
|
|
28
|
+
* @example isValidRfc3339DateTime("2024-03-15T14:30:00") // false (no offset)
|
|
29
|
+
* @example isValidRfc3339DateTime("2024-03-15T14:30:00+00:00[UTC]") // false (bracketed zone: use isValidZonedDateTime)
|
|
30
|
+
* @example isValidRfc3339DateTime("not a date") // false
|
|
31
|
+
*/
|
|
32
|
+
export function isValidRfc3339DateTime(value) {
|
|
33
|
+
return parseRfc3339(value) !== "";
|
|
34
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* - Uses Temporal.ZonedDateTime.from to test timezone validity.
|
|
5
5
|
* - Uses the `timeZoneLike` regex to check the identifier's shape: Temporal's
|
|
6
|
-
* `TimeZoneIdentifier` grammar (§
|
|
6
|
+
* `TimeZoneIdentifier` grammar (§13.31).
|
|
7
7
|
* - Accepts every IANA Zone and Link name the runtime accepts, including single-component names
|
|
8
8
|
* (`UTC`, `Japan`, `Zulu`, `EST5EDT`, `GMT+0`), in any letter case (ECMA-402 matches
|
|
9
9
|
* identifiers ASCII-case-insensitively, so `utc` is as valid as `america/new_york`).
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* - Returns false for invalid timezone formats.
|
|
13
13
|
* - Compatibility: earlier releases required a `/` in every name except `UTC` and `GMT`. To keep
|
|
14
14
|
* that narrower rule, also require `timeZone.includes("/")` or `"UTC"`/`"GMT"`.
|
|
15
|
+
* - A stored offset with seconds (`-00:44:30`) is false here and true for `isValidUtcOffset`. To
|
|
16
|
+
* check what a function with a zoneless result accepts, use
|
|
17
|
+
* `isValidTimeZone(x) || isValidUtcOffset(x)`.
|
|
15
18
|
*
|
|
16
19
|
* @param timeZone timeZone identifier to validate
|
|
17
20
|
* @returns boolean indicating validity
|
|
@@ -23,6 +26,7 @@
|
|
|
23
26
|
* @example isValidTimeZone("utc") // true (case-insensitive)
|
|
24
27
|
* @example isValidTimeZone("+05:00") // true (an offset identifier)
|
|
25
28
|
* @example isValidTimeZone("+05:00:00") // false (no seconds in an offset identifier)
|
|
29
|
+
* @example isValidTimeZone("-00:44:30") // false (a stored offset with seconds; `isValidUtcOffset` accepts it)
|
|
26
30
|
* @example "Japan".includes("/") // false (the earlier slash-only rule)
|
|
27
31
|
*/
|
|
28
32
|
export declare function isValidTimeZone(timeZone: string): boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { timeZoneLike } from "../../regex/index.js";
|
|
2
|
-
import { zonedDateTimeFrom } from "../../internal/
|
|
2
|
+
import { zonedDateTimeFrom } from "../../internal/zonedWallClock.js";
|
|
3
3
|
/**
|
|
4
4
|
* Validate whether a string is a valid time zone identifier: an IANA name or a UTC offset.
|
|
5
5
|
*
|
|
6
6
|
* - Uses Temporal.ZonedDateTime.from to test timezone validity.
|
|
7
7
|
* - Uses the `timeZoneLike` regex to check the identifier's shape: Temporal's
|
|
8
|
-
* `TimeZoneIdentifier` grammar (§
|
|
8
|
+
* `TimeZoneIdentifier` grammar (§13.31).
|
|
9
9
|
* - Accepts every IANA Zone and Link name the runtime accepts, including single-component names
|
|
10
10
|
* (`UTC`, `Japan`, `Zulu`, `EST5EDT`, `GMT+0`), in any letter case (ECMA-402 matches
|
|
11
11
|
* identifiers ASCII-case-insensitively, so `utc` is as valid as `america/new_york`).
|
|
@@ -14,6 +14,9 @@ import { zonedDateTimeFrom } from "../../internal/index.js";
|
|
|
14
14
|
* - Returns false for invalid timezone formats.
|
|
15
15
|
* - Compatibility: earlier releases required a `/` in every name except `UTC` and `GMT`. To keep
|
|
16
16
|
* that narrower rule, also require `timeZone.includes("/")` or `"UTC"`/`"GMT"`.
|
|
17
|
+
* - A stored offset with seconds (`-00:44:30`) is false here and true for `isValidUtcOffset`. To
|
|
18
|
+
* check what a function with a zoneless result accepts, use
|
|
19
|
+
* `isValidTimeZone(x) || isValidUtcOffset(x)`.
|
|
17
20
|
*
|
|
18
21
|
* @param timeZone timeZone identifier to validate
|
|
19
22
|
* @returns boolean indicating validity
|
|
@@ -25,6 +28,7 @@ import { zonedDateTimeFrom } from "../../internal/index.js";
|
|
|
25
28
|
* @example isValidTimeZone("utc") // true (case-insensitive)
|
|
26
29
|
* @example isValidTimeZone("+05:00") // true (an offset identifier)
|
|
27
30
|
* @example isValidTimeZone("+05:00:00") // false (no seconds in an offset identifier)
|
|
31
|
+
* @example isValidTimeZone("-00:44:30") // false (a stored offset with seconds; `isValidUtcOffset` accepts it)
|
|
28
32
|
* @example "Japan".includes("/") // false (the earlier slash-only rule)
|
|
29
33
|
*/
|
|
30
34
|
export function isValidTimeZone(timeZone) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@northguild/gmt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "Temporal-based date and time utilities with timezone support and polyfill integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -81,18 +81,39 @@
|
|
|
81
81
|
"duration/validate": [
|
|
82
82
|
"./dist/duration/validate/index.d.ts"
|
|
83
83
|
],
|
|
84
|
+
"duty": [
|
|
85
|
+
"./dist/duty/index.d.ts"
|
|
86
|
+
],
|
|
87
|
+
"duty/calculate": [
|
|
88
|
+
"./dist/duty/calculate/index.d.ts"
|
|
89
|
+
],
|
|
90
|
+
"duty/validate": [
|
|
91
|
+
"./dist/duty/validate/index.d.ts"
|
|
92
|
+
],
|
|
84
93
|
"instant": [
|
|
85
94
|
"./dist/instant/index.d.ts"
|
|
86
95
|
],
|
|
87
96
|
"instant/convert": [
|
|
88
97
|
"./dist/instant/convert/index.d.ts"
|
|
89
98
|
],
|
|
99
|
+
"instant/validate": [
|
|
100
|
+
"./dist/instant/validate/index.d.ts"
|
|
101
|
+
],
|
|
90
102
|
"intermodal": [
|
|
91
103
|
"./dist/intermodal/index.d.ts"
|
|
92
104
|
],
|
|
93
105
|
"intermodal/calculate": [
|
|
94
106
|
"./dist/intermodal/calculate/index.d.ts"
|
|
95
107
|
],
|
|
108
|
+
"intermodal/format": [
|
|
109
|
+
"./dist/intermodal/format/index.d.ts"
|
|
110
|
+
],
|
|
111
|
+
"intermodal/parse": [
|
|
112
|
+
"./dist/intermodal/parse/index.d.ts"
|
|
113
|
+
],
|
|
114
|
+
"intermodal/validate": [
|
|
115
|
+
"./dist/intermodal/validate/index.d.ts"
|
|
116
|
+
],
|
|
96
117
|
"interval": [
|
|
97
118
|
"./dist/interval/index.d.ts"
|
|
98
119
|
],
|
|
@@ -331,6 +352,18 @@
|
|
|
331
352
|
"types": "./dist/duration/validate/index.d.ts",
|
|
332
353
|
"default": "./dist/duration/validate/index.js"
|
|
333
354
|
},
|
|
355
|
+
"./duty": {
|
|
356
|
+
"types": "./dist/duty/index.d.ts",
|
|
357
|
+
"default": "./dist/duty/index.js"
|
|
358
|
+
},
|
|
359
|
+
"./duty/calculate": {
|
|
360
|
+
"types": "./dist/duty/calculate/index.d.ts",
|
|
361
|
+
"default": "./dist/duty/calculate/index.js"
|
|
362
|
+
},
|
|
363
|
+
"./duty/validate": {
|
|
364
|
+
"types": "./dist/duty/validate/index.d.ts",
|
|
365
|
+
"default": "./dist/duty/validate/index.js"
|
|
366
|
+
},
|
|
334
367
|
"./instant": {
|
|
335
368
|
"types": "./dist/instant/index.d.ts",
|
|
336
369
|
"default": "./dist/instant/index.js"
|
|
@@ -339,6 +372,10 @@
|
|
|
339
372
|
"types": "./dist/instant/convert/index.d.ts",
|
|
340
373
|
"default": "./dist/instant/convert/index.js"
|
|
341
374
|
},
|
|
375
|
+
"./instant/validate": {
|
|
376
|
+
"types": "./dist/instant/validate/index.d.ts",
|
|
377
|
+
"default": "./dist/instant/validate/index.js"
|
|
378
|
+
},
|
|
342
379
|
"./intermodal": {
|
|
343
380
|
"types": "./dist/intermodal/index.d.ts",
|
|
344
381
|
"default": "./dist/intermodal/index.js"
|
|
@@ -347,6 +384,18 @@
|
|
|
347
384
|
"types": "./dist/intermodal/calculate/index.d.ts",
|
|
348
385
|
"default": "./dist/intermodal/calculate/index.js"
|
|
349
386
|
},
|
|
387
|
+
"./intermodal/format": {
|
|
388
|
+
"types": "./dist/intermodal/format/index.d.ts",
|
|
389
|
+
"default": "./dist/intermodal/format/index.js"
|
|
390
|
+
},
|
|
391
|
+
"./intermodal/parse": {
|
|
392
|
+
"types": "./dist/intermodal/parse/index.d.ts",
|
|
393
|
+
"default": "./dist/intermodal/parse/index.js"
|
|
394
|
+
},
|
|
395
|
+
"./intermodal/validate": {
|
|
396
|
+
"types": "./dist/intermodal/validate/index.d.ts",
|
|
397
|
+
"default": "./dist/intermodal/validate/index.js"
|
|
398
|
+
},
|
|
350
399
|
"./interval": {
|
|
351
400
|
"types": "./dist/interval/index.d.ts",
|
|
352
401
|
"default": "./dist/interval/index.js"
|
|
@@ -11,12 +11,18 @@ description: >
|
|
|
11
11
|
(BusinessCalendar, RollConvention, isBusinessDay, addBusinessDays,
|
|
12
12
|
subtractBusinessDays, businessDaysBetween, nextBusinessDay,
|
|
13
13
|
previousBusinessDay, rollDate, mergeCalendars), overflow "constrain" month-end
|
|
14
|
-
clamping, splitIntervalByUnit* stepping
|
|
14
|
+
clamping, splitIntervalByUnit* anchor stepping, maxPieces limits,
|
|
15
15
|
intervalCount* matching bucketRange, RFC 9557 calendar strings, and the
|
|
16
|
-
correct-at-the-edges guarantees at the
|
|
17
|
-
|
|
16
|
+
correct-at-the-edges guarantees at the representable limits, and hours-of-work
|
|
17
|
+
rules over a duty log (evaluateDutyLog, dutyViolations, dutyDayFor).
|
|
18
18
|
sources:
|
|
19
|
-
- 'northguild/gmt:
|
|
19
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/core-date-operations/plain-arithmetic.mdx'
|
|
20
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/core-date-operations/durations.mdx'
|
|
21
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/core-date-operations/spans.mdx'
|
|
22
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/core-date-operations/business-calendars.mdx'
|
|
23
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/core-date-operations/calendar-systems.mdx'
|
|
24
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/intervals/*.mdx'
|
|
25
|
+
- 'northguild/gmt:apps/dox/src/content/docs/guides/concepts/correct-at-the-edges.mdx'
|
|
20
26
|
- 'northguild/gmt:packages/gmt/src/plain/calculate/index.ts'
|
|
21
27
|
- 'northguild/gmt:packages/gmt/src/duration/index.ts'
|
|
22
28
|
- 'northguild/gmt:packages/gmt/src/interval/index.ts'
|
|
@@ -29,10 +35,12 @@ sources:
|
|
|
29
35
|
- 'northguild/gmt:packages/gmt/src/calendar/business/index.ts'
|
|
30
36
|
- 'northguild/gmt:packages/gmt/src/types/business-calendar.ts'
|
|
31
37
|
- 'northguild/gmt:packages/gmt/src/types/roll-convention.ts'
|
|
38
|
+
- 'northguild/gmt:packages/gmt/src/duty/index.ts'
|
|
39
|
+
- 'northguild/gmt:packages/gmt/src/types/duty.ts'
|
|
32
40
|
metadata:
|
|
33
41
|
type: core
|
|
34
42
|
library: '@northguild/gmt'
|
|
35
|
-
library_version: '1.
|
|
43
|
+
library_version: '1.19.0'
|
|
36
44
|
---
|
|
37
45
|
|
|
38
46
|
# GMT Arithmetic
|
|
@@ -53,12 +61,40 @@ and full interval set operations.
|
|
|
53
61
|
these windows?".
|
|
54
62
|
- The user is measuring elapsed time — a profile, a trace span, a sensor
|
|
55
63
|
interval — and wants milliseconds or nanoseconds rather than a `Duration`.
|
|
64
|
+
- The user checks hours of work against rules: driving or duty caps, rest in
|
|
65
|
+
every 24 hours, a free day in seven, a monthly record of violations.
|
|
56
66
|
|
|
57
67
|
## Core rules
|
|
58
68
|
|
|
59
69
|
1. **`add*` takes a `{ unit: number }` object, not an ISO duration string.**
|
|
60
70
|
`addDate("2024-03-15", { days: 5 })` works; `addDate("2024-03-15", "P5D")`
|
|
61
71
|
returns `""`. Use `diffDateAsDuration` / `addDuration` for duration strings.
|
|
72
|
+
An amount has those two shapes, and each function takes one of them:
|
|
73
|
+
- **A unit object is checked the same way everywhere.** A unit outside the
|
|
74
|
+
function's set returns the sentinel: `addDate` takes years to days,
|
|
75
|
+
`addTime` hours to nanoseconds. So does an own key that is no unit name,
|
|
76
|
+
and an amount that is not a whole finite number. A unit set to `undefined`
|
|
77
|
+
is absent, as Temporal reads it.
|
|
78
|
+
- **`durationFromUnits` is the bridge from the object to the string.** It
|
|
79
|
+
takes all ten units and carries nothing into a larger unit. Seconds and
|
|
80
|
+
smaller are written as one decimal number of seconds. Pass its result to
|
|
81
|
+
any function that takes a duration string.
|
|
82
|
+
- **`totalUnits` totals the object in one call.** It takes exact units only:
|
|
83
|
+
days down to nanoseconds, a day being 24 hours. A year, a month or a week
|
|
84
|
+
returns `null`, as a key and as the unit asked for.
|
|
85
|
+
- **`totalDuration` totals a duration string**, and takes `relativeTo` for a
|
|
86
|
+
calendar amount. To total `{ months: 1 }`, build the string with
|
|
87
|
+
`durationFromUnits` and pass it here.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
durationFromUnits({ minutes: 15 }); // "PT15M"
|
|
91
|
+
durationFromUnits({ minutes: 90 }); // "PT90M" — not carried into hours
|
|
92
|
+
totalUnits({ minutes: 15 }, "seconds"); // 900
|
|
93
|
+
totalUnits({ weeks: 1 }, "days"); // null — write { days: 7 }
|
|
94
|
+
totalUnits("PT15M", "seconds"); // null — a duration string goes to totalDuration
|
|
95
|
+
totalDuration("PT36H", "days"); // 1.5
|
|
96
|
+
totalDuration(durationFromUnits({ months: 1 }), "days", { relativeTo: "2024-02-01" }); // 29
|
|
97
|
+
```
|
|
62
98
|
2. **Arithmetic clamps; parsers reject.** `overflow` defaults to `"constrain"`,
|
|
63
99
|
Temporal's default: January 31 plus one month is February 29, and
|
|
64
100
|
`addDate("2024-02-29", { years: 1 })` is `"2025-02-28"`. Pass
|
|
@@ -96,9 +132,10 @@ and full interval set operations.
|
|
|
96
132
|
hour on its spring-forward counts 2 hours, and a range over `Pacific/Apia`'s
|
|
97
133
|
deleted 30 December 2011 does not count that day. `intervalCountUnix` counts
|
|
98
134
|
in `options.timeZone`, UTC by default (`"local"` for the system zone).
|
|
99
|
-
5. **Calendar units need `relativeTo`.** `
|
|
135
|
+
5. **Calendar units need `relativeTo`.** `totalDuration`, `normalizeDuration`, and
|
|
100
136
|
`compareDurations` return `null`/`""` for year/month/week arithmetic without
|
|
101
|
-
a `relativeTo` anchor — a month is not a fixed length.
|
|
137
|
+
a `relativeTo` anchor — a month is not a fixed length. `totalUnits` takes no
|
|
138
|
+
`relativeTo`, so it always returns `null` for those units. A calendar-annotated
|
|
102
139
|
`relativeTo` is read as Temporal reads it: zoned when it has a time zone
|
|
103
140
|
annotation, otherwise a date, and its calendar must be a `CalendarSystem`.
|
|
104
141
|
- `round*` accept singular or plural `smallestUnit` names (`"hour"` or
|
|
@@ -213,9 +250,45 @@ and full interval set operations.
|
|
|
213
250
|
survives only if it is a working day in every input, and returns `null` for an
|
|
214
251
|
empty list. Narrow inputs with `isValidBusinessCalendar` /
|
|
215
252
|
`isValidRollConvention`.
|
|
216
|
-
13. **
|
|
217
|
-
|
|
218
|
-
|
|
253
|
+
13. **Hours of work are rules over a duty log, and every number is the
|
|
254
|
+
caller's.** A log is `{ status, start, end }[]` in the caller's own status
|
|
255
|
+
words, ordered and non-overlapping (`isValidDutyLog`). A rule is one of 13
|
|
256
|
+
`DutyRule` kinds (`cumulativeCap`, `elapsedWindow`, `requiredInterruption`,
|
|
257
|
+
`rollingCap`, `fixedPeriodCap`, `restRequirement`, `freePeriod`,
|
|
258
|
+
`restBeforeDuty`, `quota`, `dueBy`, `pattern`, `occurrenceCap`,
|
|
259
|
+
`usageLookback`) with no default limit; GMT names no regulation.
|
|
260
|
+
`evaluateDutyLog(log, at, rules, { timeZone, dayStartTime?, disambiguation? })`
|
|
261
|
+
reports every rule at one instant; `dutyViolations` lists each violation in a
|
|
262
|
+
range once, by its worst window, in the range it began in.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
evaluateDutyLog(log, "2024-01-01T21:30:00Z", [{ label: "11 driving", kind: "cumulativeCap",
|
|
266
|
+
statuses: ["driving"], cap: "PT11H", since: { statuses: ["off"], consecutive: "PT10H" } }],
|
|
267
|
+
{ timeZone: "UTC" }).violations; // [{ label: "11 driving", used: "PT11H30M", limit: "PT11H", … }]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
- `{ elapsed: "PT24H" }` slides; `{ operatorDays }`, `{ calendarDays }`,
|
|
271
|
+
`{ isoWeeks }`, `{ calendarMonths }`, `{ calendarYears }` are whole local
|
|
272
|
+
periods in `timeZone` (28 calendar days across a fall-back are 673 hours).
|
|
273
|
+
- The operator day is `dutyDayFor(instant, { timeZone, dayStartTime })`,
|
|
274
|
+
never local midnight; a rule counting `operatorDays` needs `dayStartTime`.
|
|
275
|
+
- The log is read up to `at`; unlogged time is neither work nor rest. To
|
|
276
|
+
check a roster, append the plan and set `at` to its end.
|
|
277
|
+
- A paired rest is three floors (`PairSpec`), not two integers:
|
|
278
|
+
`qualifyingRestPairs`.
|
|
279
|
+
- A count of periods is 10,000 at most, alone or times `adjacent`,
|
|
280
|
+
`lookback` or `periods`. `fixedPeriodCap.period` and `occurrenceCap.per`
|
|
281
|
+
are a `LocalPeriod`: a count, never `elapsed`.
|
|
282
|
+
- `dutyViolations` reads only the time the log covers, and each check reads
|
|
283
|
+
the log as it stood then, so a record only grows as the log does.
|
|
284
|
+
- Nested caps are separate rules, reported separately.
|
|
285
|
+
14. **Read the docs site.** This skill is a routing pointer. For full option
|
|
286
|
+
shapes, locale matrices, and code examples, read these:
|
|
287
|
+
- `https://gmt-dox.northguild.workers.dev/llms.txt` is the map of every docs page.
|
|
288
|
+
- Each page has a `.md` twin that holds its text, for example
|
|
289
|
+
`https://gmt-dox.northguild.workers.dev/guides/core-date-operations/plain-arithmetic.md`.
|
|
290
|
+
- The JSDoc of the function you intend to call ships in the installed
|
|
291
|
+
package: `node_modules/@northguild/gmt/dist/**/*.d.ts`.
|
|
219
292
|
|
|
220
293
|
## Key functions
|
|
221
294
|
|
|
@@ -231,9 +304,12 @@ and full interval set operations.
|
|
|
231
304
|
`startOfQuarterForDate`, `getLocaleStartOfWeek` (zoned boundaries: see the
|
|
232
305
|
`gmt-timezone` skill)
|
|
233
306
|
- **Durations (ISO 8601)**: `isValidDuration`, `parseDuration`, `addDuration`,
|
|
234
|
-
`subtractDuration`, `normalizeDuration`, `
|
|
307
|
+
`subtractDuration`, `normalizeDuration`, `totalDuration`, `formatDuration`,
|
|
235
308
|
`negateDuration`, `absDuration`, `compareDurations`, `getDurationUnit`,
|
|
236
309
|
`getDurationSign`
|
|
310
|
+
- **Unit objects (`{ unit: number }`)**: `durationFromUnits` (object to
|
|
311
|
+
duration string), `totalUnits` (object to one total), type
|
|
312
|
+
`ExactDurationUnit`
|
|
237
313
|
- **Diff-to-duration bridge**: `diffDateAsDuration`,
|
|
238
314
|
`diffZonedAsDuration`, `diffUnixAsDuration`, `diffUtcAsDuration`
|
|
239
315
|
- **Interval algebra (half-open, instants)**: `isValidInterval`,
|
|
@@ -247,6 +323,11 @@ and full interval set operations.
|
|
|
247
323
|
`intervalLengthDate`, `intervalDivideEquallyDate`, `mergeIntervalsDate` (each
|
|
248
324
|
with `DateTime`/`Zoned`/`Unix`/`Utc` variants where the type supports it)
|
|
249
325
|
|
|
326
|
+
- **Hours of work**: `evaluateDutyLog`, `dutyViolations`, `dutyDayFor`,
|
|
327
|
+
`dutyTotals`, `longestRun`, `qualifyingRests`, `qualifyingRestPairs`,
|
|
328
|
+
`isValidDutyLog`, types `DutyEntry`, `DutyRule`, `Period`, `LocalPeriod`,
|
|
329
|
+
`DutyReport`
|
|
330
|
+
|
|
250
331
|
## Namespace selection
|
|
251
332
|
|
|
252
333
|
- `plain/*` — timezone-free dates, times, datetimes
|
|
@@ -256,9 +337,15 @@ and full interval set operations.
|
|
|
256
337
|
- `duration/*` — ISO 8601 duration strings
|
|
257
338
|
- `span/*` — elapsed and wall-clock spans as raw numbers
|
|
258
339
|
- `interval/*` — half-open interval algebra over instant strings
|
|
340
|
+
- `duty/*` — hours-of-work rules over a duty log
|
|
259
341
|
|
|
260
342
|
## References
|
|
261
343
|
|
|
262
|
-
- [
|
|
344
|
+
- [Docs map for agents (llms.txt)](https://gmt-dox.northguild.workers.dev/llms.txt)
|
|
345
|
+
- [Plain arithmetic guide](https://gmt-dox.northguild.workers.dev/guides/core-date-operations/plain-arithmetic/)
|
|
346
|
+
- [Durations guide](https://gmt-dox.northguild.workers.dev/guides/core-date-operations/durations/)
|
|
347
|
+
- [Spans guide](https://gmt-dox.northguild.workers.dev/guides/core-date-operations/spans/)
|
|
348
|
+
- [Business calendars guide](https://gmt-dox.northguild.workers.dev/guides/core-date-operations/business-calendars/)
|
|
263
349
|
- [Interval algebra reference](/reference/interval/calculate/intersectIntervals)
|
|
264
350
|
- [Interval guides](/guides/intervals/interval-basics/)
|
|
351
|
+
- [Hours of work guide](https://gmt-dox.northguild.workers.dev/guides/intervals/hours-of-work/)
|