@northguild/gmt 1.17.0 → 1.18.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 +462 -22
- package/dist/calendar/calculate/bucketRange.d.ts +3 -3
- package/dist/calendar/calculate/bucketRange.js +6 -6
- package/dist/calendar/calculate/floorToZone.d.ts +5 -3
- package/dist/calendar/calculate/floorToZone.js +6 -5
- package/dist/calendar/calculate/getFiscalPeriod.d.ts +21 -8
- package/dist/calendar/calculate/getFiscalPeriod.js +9 -8
- package/dist/calendar/calculate/getIsoWeekDate.d.ts +10 -5
- package/dist/calendar/calculate/getIsoWeekDate.js +1 -5
- package/dist/calendar/calculate/getOrdinalDate.d.ts +10 -3
- package/dist/calendar/calculate/getOrdinalDate.js +2 -3
- package/dist/calendar/calculate/getQuarter.d.ts +21 -9
- package/dist/calendar/calculate/getQuarter.js +8 -12
- package/dist/calendar/hours/addOperatingTime.d.ts +53 -0
- package/dist/calendar/hours/addOperatingTime.js +59 -0
- package/dist/calendar/hours/index.d.ts +7 -0
- package/dist/calendar/hours/index.js +7 -0
- package/dist/calendar/hours/isOpenAt.d.ts +39 -0
- package/dist/calendar/hours/isOpenAt.js +44 -0
- package/dist/calendar/hours/nextCloseAt.d.ts +49 -0
- package/dist/calendar/hours/nextCloseAt.js +51 -0
- package/dist/calendar/hours/nextOpenAt.d.ts +45 -0
- package/dist/calendar/hours/nextOpenAt.js +47 -0
- package/dist/calendar/hours/operatingIntervals.d.ts +43 -0
- package/dist/calendar/hours/operatingIntervals.js +52 -0
- package/dist/calendar/hours/operatingTimeBetween.d.ts +40 -0
- package/dist/calendar/hours/operatingTimeBetween.js +49 -0
- package/dist/calendar/hours/recurringWindows.d.ts +61 -0
- package/dist/calendar/hours/recurringWindows.js +80 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/duration/calculate/durationAs.d.ts +13 -8
- package/dist/duration/calculate/durationAs.js +4 -8
- package/dist/duration/compare/compareDurations.d.ts +12 -6
- package/dist/duration/compare/compareDurations.js +3 -6
- package/dist/duration/format/formatDuration.d.ts +16 -4
- package/dist/duration/format/formatDuration.js +4 -5
- package/dist/duration/normalize/normalizeDuration.d.ts +39 -14
- package/dist/duration/normalize/normalizeDuration.js +6 -15
- package/dist/duration/parse/parseDuration.d.ts +21 -3
- package/dist/duration/parse/parseDuration.js +1 -3
- package/dist/instant/convert/classifyLocal.d.ts +1 -1
- package/dist/instant/convert/classifyLocal.js +1 -1
- package/dist/instant/convert/fromOffsetInstant.d.ts +3 -1
- package/dist/instant/convert/fromOffsetInstant.js +3 -1
- package/dist/instant/convert/resolveLocal.d.ts +12 -7
- package/dist/instant/convert/resolveLocal.js +6 -10
- package/dist/instant/convert/toOffsetInstant.d.ts +22 -9
- package/dist/instant/convert/toOffsetInstant.js +10 -3
- package/dist/intermodal/calculate/billingTimeline.d.ts +31 -11
- package/dist/intermodal/calculate/billingTimeline.js +2 -2
- package/dist/intermodal/calculate/chargeableDays.d.ts +13 -11
- package/dist/intermodal/calculate/chargeableDays.js +4 -9
- package/dist/intermodal/calculate/demurrageClock.d.ts +16 -7
- package/dist/intermodal/calculate/demurrageClock.js +7 -7
- package/dist/intermodal/calculate/freeTimeExpiry.d.ts +5 -4
- package/dist/intermodal/calculate/freeTimeExpiry.js +6 -6
- package/dist/internal/businessCalendar.d.ts +5 -0
- package/dist/internal/businessCalendar.js +5 -1
- package/dist/internal/cycleFieldValue.d.ts +6 -4
- package/dist/internal/cycleFieldValue.js +6 -4
- package/dist/internal/daylightTime.d.ts +33 -0
- package/dist/internal/daylightTime.js +164 -0
- package/dist/internal/durationUntilString.js +4 -3
- package/dist/internal/englishCalendarNames.js +1 -2
- package/dist/internal/epochNanoseconds.d.ts +2 -0
- package/dist/internal/epochNanoseconds.js +2 -0
- package/dist/internal/exactDuration.d.ts +37 -0
- package/dist/internal/exactDuration.js +64 -0
- package/dist/internal/exactMoment.d.ts +72 -0
- package/dist/internal/exactMoment.js +114 -0
- package/dist/internal/fiscalCalendar.d.ts +4 -3
- package/dist/internal/fiscalCalendar.js +4 -3
- package/dist/internal/formatCalendarDays.d.ts +2 -2
- package/dist/internal/formatRelativeDuration.d.ts +21 -1
- package/dist/internal/formatRelativeDuration.js +47 -7
- package/dist/internal/index.d.ts +9 -4
- package/dist/internal/index.js +9 -4
- package/dist/internal/instantFormatOptions.js +2 -1
- package/dist/internal/instantNanoseconds.d.ts +75 -9
- package/dist/internal/instantNanoseconds.js +192 -11
- package/dist/internal/joinDateTimeConnector.d.ts +1 -1
- package/dist/internal/monthGridWeekRow.d.ts +2 -1
- package/dist/internal/monthGridWeekRow.js +2 -1
- package/dist/internal/normalizeTimeZone.d.ts +2 -2
- package/dist/internal/normalizeTimeZone.js +2 -2
- package/dist/internal/operatingSchedule.d.ts +129 -0
- package/dist/internal/operatingSchedule.js +668 -0
- package/dist/internal/optionOrDefault.d.ts +18 -0
- package/dist/internal/optionOrDefault.js +20 -0
- package/dist/internal/patternToken.d.ts +2 -2
- package/dist/internal/patternToken.js +28 -13
- package/dist/internal/plainDateUntil.js +10 -6
- package/dist/internal/punctuality.d.ts +38 -0
- package/dist/internal/punctuality.js +59 -0
- package/dist/internal/readDateTimeFormatOptions.d.ts +30 -0
- package/dist/internal/readDateTimeFormatOptions.js +93 -0
- package/dist/internal/resolveDurationRelativeTo.d.ts +4 -0
- package/dist/internal/resolveDurationRelativeTo.js +11 -1
- package/dist/internal/resolveRelativeRounding.d.ts +17 -6
- package/dist/internal/resolveRelativeRounding.js +27 -7
- package/dist/internal/resolveRelativeUnit.d.ts +30 -0
- package/dist/internal/resolveRelativeUnit.js +40 -0
- package/dist/internal/splitStep.d.ts +24 -1
- package/dist/internal/splitStep.js +34 -2
- package/dist/internal/startOrEndOfZoned.js +2 -3
- package/dist/internal/temporalCompat/capabilities.d.ts +26 -0
- package/dist/internal/temporalCompat/capabilities.js +35 -3
- package/dist/internal/temporalCompat/fieldSearch.js +1 -1
- package/dist/internal/temporalCompat/index.d.ts +1 -1
- package/dist/internal/temporalCompat/index.js +1 -1
- package/dist/internal/temporalCompat/repros.d.ts +1 -1
- package/dist/internal/temporalCompat/repros.js +157 -0
- package/dist/internal/timestampEvents.d.ts +32 -0
- package/dist/internal/timestampEvents.js +76 -0
- package/dist/internal/utcZonedDateTime.d.ts +5 -2
- package/dist/internal/utcZonedDateTime.js +8 -5
- package/dist/internal/zonedBucket.js +8 -6
- package/dist/internal/zonedLocalDates.js +1 -1
- package/dist/internal/zonedTransitionSearch.d.ts +27 -0
- package/dist/internal/zonedTransitionSearch.js +218 -0
- package/dist/internal/zonedWallClock.d.ts +21 -7
- package/dist/internal/zonedWallClock.js +87 -18
- package/dist/internal/zonedWallClockOperations.d.ts +26 -13
- package/dist/internal/zonedWallClockOperations.js +87 -34
- package/dist/interval/validate/isValidInterval.d.ts +6 -3
- package/dist/interval/validate/isValidInterval.js +6 -3
- package/dist/plain/calculate/addDate.d.ts +11 -8
- package/dist/plain/calculate/addDate.js +5 -8
- package/dist/plain/calculate/addDateTime.d.ts +7 -4
- package/dist/plain/calculate/addDateTime.js +1 -4
- package/dist/plain/calculate/cycleDate.d.ts +16 -7
- package/dist/plain/calculate/cycleDate.js +3 -7
- package/dist/plain/calculate/cycleDateTime.d.ts +14 -4
- package/dist/plain/calculate/cycleDateTime.js +1 -4
- package/dist/plain/calculate/cycleTime.d.ts +10 -5
- package/dist/plain/calculate/cycleTime.js +3 -5
- package/dist/plain/calculate/diffDate.d.ts +1 -1
- package/dist/plain/calculate/diffDate.js +1 -1
- package/dist/plain/calculate/diffDateAsDuration.d.ts +1 -1
- package/dist/plain/calculate/diffDateAsDuration.js +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 +8 -3
- package/dist/plain/calculate/endOfDate.js +1 -3
- package/dist/plain/calculate/endOfDateTime.d.ts +15 -5
- package/dist/plain/calculate/endOfDateTime.js +1 -5
- package/dist/plain/calculate/endOfTime.d.ts +8 -2
- package/dist/plain/calculate/endOfTime.js +1 -2
- package/dist/plain/calculate/getLocaleWeekYear.d.ts +16 -9
- package/dist/plain/calculate/getLocaleWeekYear.js +9 -9
- package/dist/plain/calculate/getWeekOfMonth.d.ts +7 -4
- package/dist/plain/calculate/getWeekOfMonth.js +7 -4
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.d.ts +13 -6
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.js +6 -6
- package/dist/plain/calculate/getWeeksInMonth.d.ts +5 -2
- package/dist/plain/calculate/getWeeksInMonth.js +5 -2
- package/dist/plain/calculate/nextWeekday.d.ts +7 -3
- package/dist/plain/calculate/nextWeekday.js +1 -3
- package/dist/plain/calculate/previousWeekday.d.ts +7 -3
- package/dist/plain/calculate/previousWeekday.js +1 -3
- package/dist/plain/calculate/roundDate.d.ts +20 -7
- package/dist/plain/calculate/roundDate.js +3 -10
- package/dist/plain/calculate/roundDateTime.d.ts +22 -8
- package/dist/plain/calculate/roundDateTime.js +3 -11
- package/dist/plain/calculate/roundTime.d.ts +20 -4
- package/dist/plain/calculate/roundTime.js +3 -7
- package/dist/plain/calculate/setDate.d.ts +7 -5
- package/dist/plain/calculate/setDate.js +1 -5
- package/dist/plain/calculate/setDateTime.d.ts +8 -5
- package/dist/plain/calculate/setDateTime.js +1 -5
- package/dist/plain/calculate/setTime.d.ts +10 -6
- package/dist/plain/calculate/setTime.js +4 -6
- package/dist/plain/calculate/startOfDate.d.ts +8 -2
- package/dist/plain/calculate/startOfDate.js +1 -2
- package/dist/plain/calculate/startOfDateTime.d.ts +15 -2
- package/dist/plain/calculate/startOfDateTime.js +1 -2
- package/dist/plain/calculate/startOfTime.d.ts +8 -1
- package/dist/plain/calculate/startOfTime.js +1 -1
- package/dist/plain/calculate/subtractDate.d.ts +7 -4
- package/dist/plain/calculate/subtractDate.js +1 -4
- package/dist/plain/calculate/subtractDateTime.d.ts +7 -4
- package/dist/plain/calculate/subtractDateTime.js +1 -4
- package/dist/plain/compare/areDateTimesEqualBy.d.ts +13 -5
- package/dist/plain/compare/areDateTimesEqualBy.js +6 -5
- package/dist/plain/compare/areDatesEqualBy.d.ts +15 -6
- package/dist/plain/compare/areDatesEqualBy.js +8 -6
- package/dist/plain/compare/isBetweenDate.d.ts +13 -2
- package/dist/plain/compare/isBetweenDate.js +4 -4
- package/dist/plain/compare/isBetweenDateTime.d.ts +13 -2
- package/dist/plain/compare/isBetweenDateTime.js +4 -4
- package/dist/plain/compare/isBetweenTime.d.ts +13 -2
- package/dist/plain/compare/isBetweenTime.js +4 -4
- package/dist/plain/compare/isRelativeDay.d.ts +1 -1
- package/dist/plain/compare/isRelativeDay.js +1 -1
- package/dist/plain/compare/isThisUnit.d.ts +1 -1
- package/dist/plain/compare/isThisUnit.js +1 -1
- package/dist/plain/format/formatCalendar.d.ts +21 -14
- package/dist/plain/format/formatCalendar.js +21 -16
- package/dist/plain/format/formatDate.js +5 -3
- package/dist/plain/format/formatDateRange.js +4 -2
- package/dist/plain/format/formatDateTime.js +4 -2
- package/dist/plain/format/formatDateTimeRange.js +4 -2
- package/dist/plain/format/formatDateTimeToParts.d.ts +15 -4
- package/dist/plain/format/formatDateTimeToParts.js +10 -6
- package/dist/plain/format/formatDateToParts.d.ts +13 -2
- package/dist/plain/format/formatDateToParts.js +8 -4
- package/dist/plain/format/formatRelativeDate.d.ts +16 -3
- package/dist/plain/format/formatRelativeDate.js +26 -15
- package/dist/plain/format/formatRelativeDateTime.d.ts +16 -3
- package/dist/plain/format/formatRelativeDateTime.js +8 -5
- package/dist/plain/format/formatRelativeTime.d.ts +16 -3
- package/dist/plain/format/formatRelativeTime.js +21 -13
- package/dist/plain/format/formatTime.js +4 -2
- package/dist/plain/interval/intervalDifferenceDate.d.ts +9 -0
- package/dist/plain/interval/intervalDifferenceDateTime.d.ts +9 -0
- package/dist/plain/interval/intervalDifferenceTime.d.ts +9 -0
- package/dist/plain/interval/intervalDivideEquallyDate.d.ts +19 -4
- package/dist/plain/interval/intervalDivideEquallyDate.js +3 -4
- package/dist/plain/interval/intervalDivideEquallyDateTime.d.ts +19 -4
- package/dist/plain/interval/intervalDivideEquallyDateTime.js +3 -4
- package/dist/plain/interval/intervalDivideEquallyTime.d.ts +19 -4
- package/dist/plain/interval/intervalDivideEquallyTime.js +3 -4
- package/dist/plain/interval/intervalFromDurationDate.d.ts +16 -3
- package/dist/plain/interval/intervalFromDurationDate.js +1 -3
- package/dist/plain/interval/intervalFromDurationDateTime.d.ts +16 -3
- package/dist/plain/interval/intervalFromDurationDateTime.js +1 -3
- package/dist/plain/interval/intervalFromDurationTime.d.ts +9 -0
- package/dist/plain/interval/intervalIntersectionDate.d.ts +9 -0
- package/dist/plain/interval/intervalIntersectionDateTime.d.ts +9 -0
- package/dist/plain/interval/intervalIntersectionTime.d.ts +9 -0
- package/dist/plain/interval/intervalSplitAtDate.d.ts +11 -0
- package/dist/plain/interval/intervalSplitAtDate.js +2 -0
- package/dist/plain/interval/intervalSplitAtDateTime.d.ts +11 -0
- package/dist/plain/interval/intervalSplitAtDateTime.js +2 -0
- package/dist/plain/interval/intervalSplitAtTime.d.ts +11 -0
- package/dist/plain/interval/intervalSplitAtTime.js +2 -0
- package/dist/plain/interval/intervalUnionDate.d.ts +9 -0
- package/dist/plain/interval/intervalUnionDateTime.d.ts +9 -0
- package/dist/plain/interval/intervalUnionTime.d.ts +9 -0
- package/dist/plain/interval/intervalXorAllDate.d.ts +9 -0
- package/dist/plain/interval/intervalXorAllDateTime.d.ts +9 -0
- package/dist/plain/interval/intervalXorAllTime.d.ts +9 -0
- package/dist/plain/interval/intervalXorDate.d.ts +9 -0
- package/dist/plain/interval/intervalXorDateTime.d.ts +9 -0
- package/dist/plain/interval/intervalXorTime.d.ts +9 -0
- package/dist/plain/interval/mergeIntervalsDate.d.ts +9 -0
- package/dist/plain/interval/mergeIntervalsDateTime.d.ts +9 -0
- package/dist/plain/interval/mergeIntervalsTime.d.ts +9 -0
- package/dist/plain/interval/splitIntervalByUnitDate.d.ts +23 -7
- package/dist/plain/interval/splitIntervalByUnitDate.js +7 -7
- package/dist/plain/interval/splitIntervalByUnitDateTime.d.ts +22 -6
- package/dist/plain/interval/splitIntervalByUnitDateTime.js +6 -6
- package/dist/plain/interval/splitIntervalByUnitTime.d.ts +17 -4
- package/dist/plain/interval/splitIntervalByUnitTime.js +1 -4
- package/dist/plain/map/mapDatesInRange.d.ts +8 -4
- package/dist/plain/map/mapDatesInRange.js +1 -4
- package/dist/plain/parse/parseDateTimeWithPattern.d.ts +10 -7
- package/dist/plain/parse/parseDateTimeWithPattern.js +10 -7
- package/dist/plain/parse/parseDateWithPattern.d.ts +10 -7
- package/dist/plain/parse/parseDateWithPattern.js +10 -7
- package/dist/plain/parse/parseTimeWithPattern.d.ts +10 -7
- package/dist/plain/parse/parseTimeWithPattern.js +10 -7
- package/dist/plain/parse/parseUnitFromDate.d.ts +11 -3
- package/dist/plain/parse/parseUnitFromDate.js +3 -3
- package/dist/plain/parse/parseUnitFromDateTime.d.ts +11 -3
- package/dist/plain/parse/parseUnitFromDateTime.js +3 -3
- package/dist/plain/parse/parseWeekFromDate.d.ts +10 -6
- package/dist/plain/parse/parseWeekFromDate.js +2 -6
- package/dist/plain/parse/parseWeekFromDateTime.d.ts +10 -6
- package/dist/plain/parse/parseWeekFromDateTime.js +2 -6
- package/dist/plain/validate/isValidDateRange.d.ts +19 -4
- package/dist/plain/validate/isValidDateRange.js +1 -4
- package/dist/plain/validate/isValidDateTimeRange.d.ts +20 -5
- package/dist/plain/validate/isValidDateTimeRange.js +2 -5
- package/dist/plain/validate/isValidTimeRange.d.ts +20 -5
- package/dist/plain/validate/isValidTimeRange.js +2 -5
- package/dist/precision/convert/fromExcelSerial.d.ts +10 -4
- package/dist/precision/convert/fromExcelSerial.js +4 -5
- package/dist/precision/convert/fromNanoseconds.d.ts +1 -1
- package/dist/precision/convert/fromNanoseconds.js +1 -1
- package/dist/precision/convert/toExcelSerial.d.ts +9 -3
- package/dist/precision/convert/toExcelSerial.js +3 -4
- package/dist/precision/convert/toNanoseconds.d.ts +11 -6
- package/dist/precision/convert/toNanoseconds.js +11 -6
- package/dist/precision/validate/isValidInstant.d.ts +12 -3
- package/dist/precision/validate/isValidInstant.js +12 -3
- package/dist/span/calculate/spanMs.d.ts +10 -4
- package/dist/span/calculate/spanMs.js +10 -4
- package/dist/span/calculate/spanNs.d.ts +10 -4
- package/dist/span/calculate/spanNs.js +10 -4
- package/dist/span/validate/isValidSpan.d.ts +8 -3
- package/dist/span/validate/isValidSpan.js +8 -3
- package/dist/transport/calculate/bestAvailable.d.ts +47 -0
- package/dist/transport/calculate/bestAvailable.js +76 -0
- package/dist/transport/calculate/crossingTime.d.ts +58 -0
- package/dist/transport/calculate/crossingTime.js +76 -0
- package/dist/transport/calculate/cutoffAt.d.ts +90 -0
- package/dist/transport/calculate/cutoffAt.js +209 -0
- package/dist/transport/calculate/cutoffSchedule.d.ts +70 -0
- package/dist/transport/calculate/cutoffSchedule.js +71 -0
- package/dist/transport/calculate/dwellTime.d.ts +16 -7
- package/dist/transport/calculate/dwellTime.js +12 -8
- package/dist/transport/calculate/estimateDrift.d.ts +65 -0
- package/dist/transport/calculate/estimateDrift.js +75 -0
- package/dist/transport/calculate/index.d.ts +8 -0
- package/dist/transport/calculate/index.js +8 -0
- package/dist/transport/calculate/nextDeparture.d.ts +78 -0
- package/dist/transport/calculate/nextDeparture.js +131 -0
- package/dist/transport/calculate/punctualityRate.d.ts +42 -0
- package/dist/transport/calculate/punctualityRate.js +59 -0
- package/dist/transport/calculate/scheduleDelivery.d.ts +150 -0
- package/dist/transport/calculate/scheduleDelivery.js +300 -0
- package/dist/transport/calculate/transitTime.d.ts +21 -3
- package/dist/transport/calculate/transitTime.js +29 -46
- package/dist/transport/compare/classifyPunctuality.d.ts +46 -0
- package/dist/transport/compare/classifyPunctuality.js +64 -0
- package/dist/transport/compare/index.d.ts +4 -0
- package/dist/transport/compare/index.js +4 -0
- package/dist/transport/compare/isPastCutoff.d.ts +33 -0
- package/dist/transport/compare/isPastCutoff.js +48 -0
- package/dist/transport/compare/scheduleDeviation.d.ts +37 -0
- package/dist/transport/compare/scheduleDeviation.js +53 -0
- package/dist/transport/compare/timeToCutoff.d.ts +31 -0
- package/dist/transport/compare/timeToCutoff.js +47 -0
- package/dist/transport/convert/etaAtZone.d.ts +7 -0
- package/dist/transport/convert/etaAtZone.js +9 -4
- package/dist/transport/index.d.ts +1 -0
- package/dist/transport/index.js +1 -0
- package/dist/types/business-calendar.d.ts +19 -14
- package/dist/types/calendar-options.d.ts +15 -3
- package/dist/types/date-cycle-field.d.ts +5 -0
- package/dist/types/date-duration-unit.d.ts +4 -0
- package/dist/types/date-time-cycle-field.d.ts +4 -0
- package/dist/types/date-time-duration-units.d.ts +4 -0
- package/dist/types/date-time-unit.d.ts +4 -0
- package/dist/types/date-unit.d.ts +4 -0
- package/dist/types/disambiguation.d.ts +8 -0
- package/dist/types/duration-relative-to.d.ts +8 -0
- package/dist/types/duration-string-options.d.ts +28 -0
- package/dist/types/fiscal-calendar.d.ts +1 -1
- package/dist/types/fractional-digit.d.ts +5 -0
- package/dist/types/free-time-options.d.ts +21 -11
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +2 -1
- package/dist/types/interval.d.ts +8 -1
- package/dist/types/offset.d.ts +9 -0
- package/dist/types/operating-schedule.d.ts +71 -0
- package/dist/types/overflow.d.ts +6 -0
- package/dist/types/relative-rounding-method.d.ts +6 -0
- package/dist/types/relative-time-options.d.ts +33 -5
- package/dist/types/rounding-options.d.ts +27 -0
- package/dist/types/time-cycle-field.d.ts +4 -0
- package/dist/types/time-duration-unit.d.ts +4 -0
- package/dist/types/time-unit.d.ts +4 -0
- package/dist/types/transport-timestamps.d.ts +54 -0
- package/dist/types/transport-timestamps.js +0 -0
- package/dist/unix/calculate/addUnix.d.ts +19 -5
- package/dist/unix/calculate/addUnix.js +1 -5
- package/dist/unix/calculate/diffUnix.d.ts +13 -3
- package/dist/unix/calculate/diffUnix.js +1 -3
- package/dist/unix/calculate/diffUnixAsDuration.d.ts +13 -3
- package/dist/unix/calculate/diffUnixAsDuration.js +1 -3
- package/dist/unix/calculate/endOfQuarterForUnix.d.ts +13 -3
- package/dist/unix/calculate/endOfQuarterForUnix.js +1 -3
- package/dist/unix/calculate/endOfUnix.d.ts +20 -4
- package/dist/unix/calculate/endOfUnix.js +1 -4
- package/dist/unix/calculate/isBetweenUnix.d.ts +26 -4
- package/dist/unix/calculate/isBetweenUnix.js +4 -6
- package/dist/unix/calculate/roundUnix.d.ts +31 -3
- package/dist/unix/calculate/roundUnix.js +3 -6
- package/dist/unix/calculate/setUnix.d.ts +35 -9
- package/dist/unix/calculate/setUnix.js +4 -13
- package/dist/unix/calculate/startOfQuarterForUnix.d.ts +13 -3
- package/dist/unix/calculate/startOfQuarterForUnix.js +1 -3
- package/dist/unix/calculate/startOfUnix.d.ts +20 -4
- package/dist/unix/calculate/startOfUnix.js +1 -4
- package/dist/unix/calculate/subtractUnix.d.ts +19 -5
- package/dist/unix/calculate/subtractUnix.js +1 -5
- package/dist/unix/compare/areUnixEqual.d.ts +7 -1
- package/dist/unix/compare/areUnixEqual.js +1 -1
- package/dist/unix/compare/areUnixEqualBy.d.ts +24 -7
- package/dist/unix/compare/areUnixEqualBy.js +13 -9
- package/dist/unix/compare/isAfterUnix.d.ts +7 -1
- package/dist/unix/compare/isAfterUnix.js +1 -1
- package/dist/unix/compare/isBeforeUnix.d.ts +7 -1
- package/dist/unix/compare/isBeforeUnix.js +1 -1
- package/dist/unix/convert/convertUnixToPlainDate.d.ts +14 -4
- package/dist/unix/convert/convertUnixToPlainDate.js +2 -4
- package/dist/unix/convert/convertUnixToPlainDateTime.d.ts +14 -4
- package/dist/unix/convert/convertUnixToPlainDateTime.js +2 -4
- package/dist/unix/convert/convertUnixToPlainTime.d.ts +14 -4
- package/dist/unix/convert/convertUnixToPlainTime.js +2 -4
- package/dist/unix/convert/convertUnixToUtc.d.ts +9 -4
- package/dist/unix/convert/convertUnixToUtc.js +3 -4
- package/dist/unix/convert/convertUnixToZoned.d.ts +10 -5
- package/dist/unix/convert/convertUnixToZoned.js +4 -5
- package/dist/unix/format/formatCalendarUnix.d.ts +27 -19
- package/dist/unix/format/formatCalendarUnix.js +4 -5
- package/dist/unix/format/formatRelativeUnix.d.ts +54 -5
- package/dist/unix/format/formatRelativeUnix.js +3 -5
- package/dist/unix/format/formatUnix.d.ts +24 -6
- package/dist/unix/format/formatUnix.js +8 -7
- package/dist/unix/get/getUnixNow.d.ts +8 -3
- package/dist/unix/get/getUnixNow.js +1 -3
- package/dist/unix/interval/intervalCountUnix.d.ts +14 -5
- package/dist/unix/interval/intervalCountUnix.js +2 -5
- package/dist/unix/interval/intervalDifferenceUnix.d.ts +6 -0
- package/dist/unix/interval/intervalDivideEquallyUnix.d.ts +18 -4
- package/dist/unix/interval/intervalDivideEquallyUnix.js +5 -4
- package/dist/unix/interval/intervalFromDurationUnix.d.ts +33 -5
- package/dist/unix/interval/intervalFromDurationUnix.js +6 -5
- package/dist/unix/interval/intervalIntersectionUnix.d.ts +6 -0
- package/dist/unix/interval/intervalLengthUnix.d.ts +16 -6
- package/dist/unix/interval/intervalLengthUnix.js +4 -6
- package/dist/unix/interval/intervalOverlappingDaysUnix.d.ts +13 -3
- package/dist/unix/interval/intervalOverlappingDaysUnix.js +1 -3
- package/dist/unix/interval/intervalSplitAtUnix.d.ts +8 -0
- package/dist/unix/interval/intervalSplitAtUnix.js +2 -0
- package/dist/unix/interval/intervalUnionUnix.d.ts +6 -0
- package/dist/unix/interval/intervalXorAllUnix.d.ts +6 -0
- package/dist/unix/interval/intervalXorUnix.d.ts +6 -0
- package/dist/unix/interval/mergeIntervalsUnix.d.ts +6 -0
- package/dist/unix/interval/splitIntervalByUnitUnix.d.ts +42 -11
- package/dist/unix/interval/splitIntervalByUnitUnix.js +21 -16
- package/dist/unix/parse/parseDateFromUnix.d.ts +13 -2
- package/dist/unix/parse/parseDateFromUnix.js +1 -2
- package/dist/unix/parse/parseDayFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseDayFromUnix.js +2 -2
- package/dist/unix/parse/parseDayOfWeekFromUnix.d.ts +13 -1
- package/dist/unix/parse/parseDayOfWeekFromUnix.js +1 -1
- package/dist/unix/parse/parseHourFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseHourFromUnix.js +2 -2
- package/dist/unix/parse/parseMicrosecondFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseMicrosecondFromUnix.js +2 -2
- package/dist/unix/parse/parseMillisecondFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseMillisecondFromUnix.js +2 -2
- package/dist/unix/parse/parseMinuteFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseMinuteFromUnix.js +2 -2
- package/dist/unix/parse/parseMonthFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseMonthFromUnix.js +2 -2
- package/dist/unix/parse/parseNanosecondFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseNanosecondFromUnix.js +2 -2
- package/dist/unix/parse/parseSecondFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseSecondFromUnix.js +2 -2
- package/dist/unix/parse/parseTimeFromUnix.d.ts +13 -2
- package/dist/unix/parse/parseTimeFromUnix.js +1 -2
- package/dist/unix/parse/parseUnitFromUnix.d.ts +22 -3
- package/dist/unix/parse/parseUnitFromUnix.js +2 -3
- package/dist/unix/parse/parseWeekFromUnix.d.ts +23 -7
- package/dist/unix/parse/parseWeekFromUnix.js +3 -7
- package/dist/unix/parse/parseYearFromUnix.d.ts +14 -2
- package/dist/unix/parse/parseYearFromUnix.js +2 -2
- package/dist/unix/validate/isValidUnixRange.d.ts +20 -4
- package/dist/unix/validate/isValidUnixRange.js +1 -4
- package/dist/utc/calculate/addUtc.d.ts +7 -4
- package/dist/utc/calculate/addUtc.js +1 -4
- 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/endOfUtc.d.ts +16 -3
- package/dist/utc/calculate/endOfUtc.js +2 -3
- package/dist/utc/calculate/isBetweenUtc.d.ts +13 -2
- package/dist/utc/calculate/isBetweenUtc.js +4 -4
- package/dist/utc/calculate/roundUtc.d.ts +26 -9
- package/dist/utc/calculate/roundUtc.js +3 -12
- package/dist/utc/calculate/setUtc.d.ts +7 -4
- package/dist/utc/calculate/setUtc.js +1 -4
- package/dist/utc/calculate/startOfUtc.d.ts +15 -2
- package/dist/utc/calculate/startOfUtc.js +1 -2
- package/dist/utc/calculate/subtractUtc.d.ts +7 -4
- package/dist/utc/calculate/subtractUtc.js +1 -4
- package/dist/utc/compare/areUtcEqualBy.d.ts +9 -3
- package/dist/utc/compare/areUtcEqualBy.js +2 -3
- package/dist/utc/convert/convertUtcToPlainDate.d.ts +8 -3
- package/dist/utc/convert/convertUtcToPlainDate.js +5 -6
- package/dist/utc/convert/convertUtcToPlainDateTime.d.ts +8 -3
- package/dist/utc/convert/convertUtcToPlainDateTime.js +5 -6
- package/dist/utc/convert/convertUtcToPlainTime.d.ts +8 -3
- package/dist/utc/convert/convertUtcToPlainTime.js +5 -6
- package/dist/utc/convert/convertUtcToUnix.d.ts +9 -4
- package/dist/utc/convert/convertUtcToUnix.js +3 -4
- package/dist/utc/convert/convertUtcToZoned.d.ts +1 -1
- package/dist/utc/convert/convertUtcToZoned.js +1 -1
- package/dist/utc/format/formatCalendarUtc.d.ts +19 -8
- package/dist/utc/format/formatCalendarUtc.js +8 -6
- package/dist/utc/format/formatHttp.d.ts +1 -1
- package/dist/utc/format/formatHttp.js +1 -1
- package/dist/utc/format/formatRelativeUtc.d.ts +30 -10
- package/dist/utc/format/formatRelativeUtc.js +9 -11
- package/dist/utc/format/formatUtc.d.ts +17 -15
- package/dist/utc/format/formatUtc.js +8 -8
- package/dist/utc/interval/intervalDifferenceUtc.d.ts +6 -0
- package/dist/utc/interval/intervalDivideEquallyUtc.d.ts +18 -4
- package/dist/utc/interval/intervalDivideEquallyUtc.js +5 -4
- package/dist/utc/interval/intervalFromDurationUtc.d.ts +13 -3
- package/dist/utc/interval/intervalFromDurationUtc.js +1 -3
- package/dist/utc/interval/intervalIntersectionUtc.d.ts +6 -0
- package/dist/utc/interval/intervalSplitAtUtc.d.ts +8 -0
- package/dist/utc/interval/intervalSplitAtUtc.js +2 -0
- package/dist/utc/interval/intervalUnionUtc.d.ts +6 -0
- package/dist/utc/interval/intervalXorAllUtc.d.ts +6 -0
- package/dist/utc/interval/intervalXorUtc.d.ts +6 -0
- package/dist/utc/interval/mergeIntervalsUtc.d.ts +6 -0
- package/dist/utc/interval/splitIntervalByUnitUtc.d.ts +19 -6
- package/dist/utc/interval/splitIntervalByUnitUtc.js +6 -6
- package/dist/utc/parse/parseDateFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseDateFromUtc.js +1 -3
- package/dist/utc/parse/parseDayFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseDayFromUtc.js +1 -3
- package/dist/utc/parse/parseDayOfWeekFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseDayOfWeekFromUtc.js +4 -6
- package/dist/utc/parse/parseHourFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseHourFromUtc.js +1 -3
- package/dist/utc/parse/parseHttp.d.ts +1 -1
- package/dist/utc/parse/parseHttp.js +1 -1
- package/dist/utc/parse/parseMicrosecondFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseMicrosecondFromUtc.js +1 -3
- package/dist/utc/parse/parseMillisecondFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseMillisecondFromUtc.js +1 -3
- package/dist/utc/parse/parseMinuteFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseMinuteFromUtc.js +1 -3
- package/dist/utc/parse/parseMonthFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseMonthFromUtc.js +1 -3
- package/dist/utc/parse/parseNanosecondFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseNanosecondFromUtc.js +1 -3
- package/dist/utc/parse/parseSecondFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseSecondFromUtc.js +1 -3
- package/dist/utc/parse/parseTimeFromUtc.d.ts +8 -3
- package/dist/utc/parse/parseTimeFromUtc.js +5 -6
- package/dist/utc/parse/parseUnitFromUtc.d.ts +17 -5
- package/dist/utc/parse/parseUnitFromUtc.js +6 -8
- package/dist/utc/parse/parseWeekFromUtc.d.ts +18 -10
- package/dist/utc/parse/parseWeekFromUtc.js +7 -13
- package/dist/utc/parse/parseYearFromUtc.d.ts +7 -3
- package/dist/utc/parse/parseYearFromUtc.js +1 -3
- package/dist/utc/validate/isValidUtcRange.d.ts +16 -5
- package/dist/utc/validate/isValidUtcRange.js +2 -5
- package/dist/zoned/calculate/addZoned.d.ts +20 -10
- package/dist/zoned/calculate/addZoned.js +6 -13
- package/dist/zoned/calculate/cycleZoned.d.ts +33 -8
- package/dist/zoned/calculate/cycleZoned.js +1 -8
- package/dist/zoned/calculate/diffZoned.d.ts +1 -1
- package/dist/zoned/calculate/diffZoned.js +1 -1
- package/dist/zoned/calculate/diffZonedAsDuration.d.ts +1 -1
- package/dist/zoned/calculate/diffZonedAsDuration.js +1 -1
- package/dist/zoned/calculate/endOfQuarterForZoned.d.ts +9 -2
- package/dist/zoned/calculate/endOfQuarterForZoned.js +4 -5
- package/dist/zoned/calculate/endOfZoned.d.ts +16 -3
- package/dist/zoned/calculate/endOfZoned.js +2 -3
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.d.ts +10 -3
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.js +5 -6
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.d.ts +7 -1
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.js +3 -4
- package/dist/zoned/calculate/roundZoned.d.ts +21 -4
- package/dist/zoned/calculate/roundZoned.js +3 -7
- package/dist/zoned/calculate/setZoned.d.ts +25 -8
- package/dist/zoned/calculate/setZoned.js +4 -12
- package/dist/zoned/calculate/startOfQuarterForZoned.d.ts +7 -2
- package/dist/zoned/calculate/startOfQuarterForZoned.js +3 -5
- package/dist/zoned/calculate/startOfZoned.d.ts +15 -3
- package/dist/zoned/calculate/startOfZoned.js +1 -3
- package/dist/zoned/calculate/subtractZoned.d.ts +20 -10
- package/dist/zoned/calculate/subtractZoned.js +6 -13
- package/dist/zoned/compare/areZonedEqualBy.d.ts +14 -5
- package/dist/zoned/compare/areZonedEqualBy.js +7 -5
- package/dist/zoned/compare/isBetweenZoned.d.ts +13 -1
- package/dist/zoned/compare/isBetweenZoned.js +4 -3
- package/dist/zoned/compare/isInDaylightSaving.d.ts +38 -11
- package/dist/zoned/compare/isInDaylightSaving.js +40 -44
- package/dist/zoned/convert/convertPlainDateTimeToZoned.d.ts +18 -5
- package/dist/zoned/convert/convertPlainDateTimeToZoned.js +6 -11
- package/dist/zoned/convert/convertZonedToUnix.d.ts +9 -4
- package/dist/zoned/convert/convertZonedToUnix.js +2 -4
- package/dist/zoned/convert/convertZonedToZoned.d.ts +1 -1
- package/dist/zoned/convert/convertZonedToZoned.js +1 -1
- package/dist/zoned/format/formatCalendarZoned.d.ts +18 -12
- package/dist/zoned/format/formatCalendarZoned.js +13 -9
- package/dist/zoned/format/formatRelativeZoned.d.ts +41 -12
- package/dist/zoned/format/formatRelativeZoned.js +7 -4
- package/dist/zoned/format/formatRfc2822.d.ts +2 -2
- package/dist/zoned/format/formatRfc2822.js +2 -2
- package/dist/zoned/format/formatRfc3339.d.ts +2 -3
- package/dist/zoned/format/formatRfc3339.js +2 -3
- package/dist/zoned/format/formatTimeZoneName.d.ts +12 -3
- package/dist/zoned/format/formatTimeZoneName.js +5 -4
- package/dist/zoned/format/formatZonedDateTime.js +2 -1
- package/dist/zoned/format/formatZonedRange.js +2 -1
- package/dist/zoned/format/formatZonedToParts.d.ts +15 -4
- package/dist/zoned/format/formatZonedToParts.js +8 -5
- package/dist/zoned/get/getDstTransitions.d.ts +9 -10
- package/dist/zoned/get/getDstTransitions.js +12 -3
- package/dist/zoned/get/getTimeZoneOffset.d.ts +4 -1
- package/dist/zoned/get/getTimeZoneOffset.js +6 -3
- package/dist/zoned/get/getZonedNow.d.ts +13 -1
- package/dist/zoned/get/getZonedNow.js +12 -3
- package/dist/zoned/interval/intervalDifferenceZoned.d.ts +9 -0
- package/dist/zoned/interval/intervalDivideEquallyZoned.d.ts +22 -4
- package/dist/zoned/interval/intervalDivideEquallyZoned.js +6 -4
- package/dist/zoned/interval/intervalFromDurationZoned.d.ts +29 -10
- package/dist/zoned/interval/intervalFromDurationZoned.js +6 -13
- package/dist/zoned/interval/intervalIntersectionZoned.d.ts +9 -0
- package/dist/zoned/interval/intervalSplitAtZoned.d.ts +11 -0
- package/dist/zoned/interval/intervalSplitAtZoned.js +2 -0
- package/dist/zoned/interval/intervalUnionZoned.d.ts +9 -0
- package/dist/zoned/interval/intervalXorAllZoned.d.ts +9 -0
- package/dist/zoned/interval/intervalXorZoned.d.ts +9 -0
- package/dist/zoned/interval/mergeIntervalsZoned.d.ts +9 -0
- package/dist/zoned/interval/splitIntervalByUnitZoned.d.ts +27 -6
- package/dist/zoned/interval/splitIntervalByUnitZoned.js +11 -6
- package/dist/zoned/map/mapZonedDatesInRange.d.ts +9 -4
- package/dist/zoned/map/mapZonedDatesInRange.js +2 -4
- package/dist/zoned/parse/parseRfc2822.d.ts +1 -1
- package/dist/zoned/parse/parseRfc2822.js +1 -1
- package/dist/zoned/parse/parseUnitFromZoned.d.ts +9 -3
- package/dist/zoned/parse/parseUnitFromZoned.js +1 -3
- package/dist/zoned/parse/parseWeekFromZoned.d.ts +10 -3
- package/dist/zoned/parse/parseWeekFromZoned.js +2 -3
- package/dist/zoned/validate/hasDaylightSaving.d.ts +42 -11
- package/dist/zoned/validate/hasDaylightSaving.js +47 -31
- package/dist/zoned/validate/isValidZonedDateTime.d.ts +13 -0
- package/dist/zoned/validate/isValidZonedDateTime.js +14 -1
- package/dist/zoned/validate/isValidZonedRange.d.ts +15 -4
- package/dist/zoned/validate/isValidZonedRange.js +1 -4
- package/package.json +18 -5
- package/skills/gmt-arithmetic/SKILL.md +1 -1
- package/skills/gmt-basics/SKILL.md +10 -1
- package/skills/gmt-integration/SKILL.md +10 -5
- package/skills/gmt-timezone/SKILL.md +150 -21
- package/dist/internal/resolveReadingTimeZone.d.ts +0 -11
- package/dist/internal/resolveReadingTimeZone.js +0 -18
- package/dist/types/duration-unit.d.ts +0 -5
- /package/dist/types/{duration-unit.js → operating-schedule.js} +0 -0
|
@@ -4,19 +4,21 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
4
4
|
*
|
|
5
5
|
* - Equality means both values share the same start-of-`unit` boundary, so
|
|
6
6
|
* `"month"` requires the same month AND year — March 2023 and March 2024 are
|
|
7
|
-
* NOT equal by month
|
|
8
|
-
* `
|
|
9
|
-
* callers expecting a bare "same month-of-year"
|
|
7
|
+
* NOT equal by month. A calendar month is a year and a month together, as in
|
|
8
|
+
* Temporal's `PlainYearMonth`, not a bare month-of-year number. This is a
|
|
9
|
+
* common point of confusion for callers expecting a bare "same month-of-year"
|
|
10
|
+
* comparison.
|
|
11
|
+
* - Comparison: date-fns's `isSameMonth` and Luxon's `dt.hasSame(other, "month")`
|
|
12
|
+
* give the same answer.
|
|
10
13
|
* - `"day"` matches `areDatesEqual` for PlainDate inputs only: `areDatesEqual` also accepts
|
|
11
14
|
* PlainDateTime strings (`areDatesEqual("2024-01-01", "2024-01-01T10:00")` is `true`), while this
|
|
12
15
|
* function accepts PlainDate strings only (`areDatesEqualBy` with those inputs and `"day"` is
|
|
13
16
|
* `false`).
|
|
14
17
|
* - `"year"`, `"month"`, `"week"` are computed via `startOfDate`.
|
|
15
18
|
* - `unit` accepts the singular or plural name (`"day"` or `"days"`), as Temporal does.
|
|
16
|
-
* - `weekStartsOn` other than `"monday"` or `"sunday"` returns false.
|
|
17
19
|
* - Returns false for an unsupported unit or invalid input.
|
|
18
20
|
*
|
|
19
|
-
* Mapping from date-fns
|
|
21
|
+
* Mapping from date-fns:
|
|
20
22
|
* - `isSameDay(a, b)` → `areDatesEqualBy(a, b, "day")`
|
|
21
23
|
* - `isSameWeek(a, b, options)` → `areDatesEqualBy(a, b, "week", { weekStartsOn })`
|
|
22
24
|
* - `isSameMonth(a, b)` → `areDatesEqualBy(a, b, "month")`
|
|
@@ -25,7 +27,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
25
27
|
* @param value1 first ISO date string
|
|
26
28
|
* @param value2 second ISO date string
|
|
27
29
|
* @param unit date unit to compare by ("year" | "month" | "week" | "day", or its plural)
|
|
28
|
-
* @param optionsArg
|
|
30
|
+
* @param optionsArg How the week is defined
|
|
29
31
|
* @returns true if both dates share the same start-of-unit boundary, false on an unsupported unit or invalid input
|
|
30
32
|
*
|
|
31
33
|
* @example areDatesEqualBy("2024-03-15", "2024-03-20", "month") // true
|
|
@@ -37,5 +39,12 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
37
39
|
* @example areDatesEqualBy("invalid", "2024-03-15", "month") // false
|
|
38
40
|
*/
|
|
39
41
|
export declare function areDatesEqualBy(value1: string, value2: string, unit: Temporal.SmallestUnit<Temporal.DateUnit>, optionsArg?: {
|
|
42
|
+
/**
|
|
43
|
+
* The first day of the week, which sets where a `"week"` unit starts. `"monday"` is the ISO
|
|
44
|
+
* 8601 week, Monday to Sunday; `"sunday"` runs Sunday to Saturday. Any other value returns
|
|
45
|
+
* false, whatever the unit.
|
|
46
|
+
*
|
|
47
|
+
* @defaultValue `"monday"`
|
|
48
|
+
*/
|
|
40
49
|
weekStartsOn?: "monday" | "sunday";
|
|
41
50
|
}): boolean;
|
|
@@ -11,19 +11,21 @@ const supported = ["year", "month", "week", "day"];
|
|
|
11
11
|
*
|
|
12
12
|
* - Equality means both values share the same start-of-`unit` boundary, so
|
|
13
13
|
* `"month"` requires the same month AND year — March 2023 and March 2024 are
|
|
14
|
-
* NOT equal by month
|
|
15
|
-
* `
|
|
16
|
-
* callers expecting a bare "same month-of-year"
|
|
14
|
+
* NOT equal by month. A calendar month is a year and a month together, as in
|
|
15
|
+
* Temporal's `PlainYearMonth`, not a bare month-of-year number. This is a
|
|
16
|
+
* common point of confusion for callers expecting a bare "same month-of-year"
|
|
17
|
+
* comparison.
|
|
18
|
+
* - Comparison: date-fns's `isSameMonth` and Luxon's `dt.hasSame(other, "month")`
|
|
19
|
+
* give the same answer.
|
|
17
20
|
* - `"day"` matches `areDatesEqual` for PlainDate inputs only: `areDatesEqual` also accepts
|
|
18
21
|
* PlainDateTime strings (`areDatesEqual("2024-01-01", "2024-01-01T10:00")` is `true`), while this
|
|
19
22
|
* function accepts PlainDate strings only (`areDatesEqualBy` with those inputs and `"day"` is
|
|
20
23
|
* `false`).
|
|
21
24
|
* - `"year"`, `"month"`, `"week"` are computed via `startOfDate`.
|
|
22
25
|
* - `unit` accepts the singular or plural name (`"day"` or `"days"`), as Temporal does.
|
|
23
|
-
* - `weekStartsOn` other than `"monday"` or `"sunday"` returns false.
|
|
24
26
|
* - Returns false for an unsupported unit or invalid input.
|
|
25
27
|
*
|
|
26
|
-
* Mapping from date-fns
|
|
28
|
+
* Mapping from date-fns:
|
|
27
29
|
* - `isSameDay(a, b)` → `areDatesEqualBy(a, b, "day")`
|
|
28
30
|
* - `isSameWeek(a, b, options)` → `areDatesEqualBy(a, b, "week", { weekStartsOn })`
|
|
29
31
|
* - `isSameMonth(a, b)` → `areDatesEqualBy(a, b, "month")`
|
|
@@ -32,7 +34,7 @@ const supported = ["year", "month", "week", "day"];
|
|
|
32
34
|
* @param value1 first ISO date string
|
|
33
35
|
* @param value2 second ISO date string
|
|
34
36
|
* @param unit date unit to compare by ("year" | "month" | "week" | "day", or its plural)
|
|
35
|
-
* @param optionsArg
|
|
37
|
+
* @param optionsArg How the week is defined
|
|
36
38
|
* @returns true if both dates share the same start-of-unit boundary, false on an unsupported unit or invalid input
|
|
37
39
|
*
|
|
38
40
|
* @example areDatesEqualBy("2024-03-15", "2024-03-20", "month") // true
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* - Uses Temporal.PlainDate.compare to compare dates.
|
|
5
5
|
* - Returns false if start > end (invalid range).
|
|
6
6
|
* - Returns false if any input is invalid.
|
|
7
|
-
* - Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
|
|
8
7
|
*
|
|
9
8
|
* @param date ISO PlainDate string to check
|
|
10
9
|
* @param start ISO PlainDate string for the start of the range
|
|
11
10
|
* @param end ISO PlainDate string for the end of the range
|
|
12
|
-
* @param options
|
|
11
|
+
* @param options Whether each end of the range counts as inside it
|
|
13
12
|
* @returns boolean indicating whether date is between start and end
|
|
14
13
|
*
|
|
15
14
|
* @example isBetweenDate("2024-02-29", "2024-02-01", "2024-02-28") // false
|
|
@@ -21,6 +20,18 @@
|
|
|
21
20
|
* @example isBetweenDate("2024-02-29", "2024-02-01", "invalid") // false
|
|
22
21
|
*/
|
|
23
22
|
export declare function isBetweenDate(date: string, start: string, end: string, options?: {
|
|
23
|
+
/**
|
|
24
|
+
* Whether `date` equal to `start` counts as inside the range. `false` requires it to
|
|
25
|
+
* be after `start`.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue `true`
|
|
28
|
+
*/
|
|
24
29
|
inclusiveStart?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether `date` equal to `end` counts as inside the range. `false` requires it to be
|
|
32
|
+
* before `end`.
|
|
33
|
+
*
|
|
34
|
+
* @defaultValue `true`
|
|
35
|
+
*/
|
|
25
36
|
inclusiveEnd?: boolean;
|
|
26
37
|
}): boolean;
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { isValidDate } from "../validate/index.js";
|
|
4
4
|
import { isOptionsArgument } from "../../internal/isObject.js";
|
|
5
|
+
import { optionOrDefault } from "../../internal/optionOrDefault.js";
|
|
5
6
|
/**
|
|
6
7
|
* Return true when `date` is between `start` and `end` (inclusive by default).
|
|
7
8
|
*
|
|
8
9
|
* - Uses Temporal.PlainDate.compare to compare dates.
|
|
9
10
|
* - Returns false if start > end (invalid range).
|
|
10
11
|
* - Returns false if any input is invalid.
|
|
11
|
-
* - Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
|
|
12
12
|
*
|
|
13
13
|
* @param date ISO PlainDate string to check
|
|
14
14
|
* @param start ISO PlainDate string for the start of the range
|
|
15
15
|
* @param end ISO PlainDate string for the end of the range
|
|
16
|
-
* @param options
|
|
16
|
+
* @param options Whether each end of the range counts as inside it
|
|
17
17
|
* @returns boolean indicating whether date is between start and end
|
|
18
18
|
*
|
|
19
19
|
* @example isBetweenDate("2024-02-29", "2024-02-01", "2024-02-28") // false
|
|
@@ -33,8 +33,8 @@ export function isBetweenDate(date, start, end, options) {
|
|
|
33
33
|
// reading of it gives `false`: ECMA-402 reads a boolean option through ToBoolean (null → false),
|
|
34
34
|
// and the house rule rejects an invalid member outright — neither yields `true`. So `null`
|
|
35
35
|
// behaves here exactly as `0` and `""` already do.
|
|
36
|
-
const inclusiveStart = options?.inclusiveStart
|
|
37
|
-
const inclusiveEnd = options?.inclusiveEnd
|
|
36
|
+
const inclusiveStart = optionOrDefault(options?.inclusiveStart, true);
|
|
37
|
+
const inclusiveEnd = optionOrDefault(options?.inclusiveEnd, true);
|
|
38
38
|
if (!isValidDate(date) || !isValidDate(start) || !isValidDate(end)) {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* - Uses Temporal.PlainDateTime.compare to compare date-times.
|
|
5
5
|
* - Returns false if start > end (invalid range).
|
|
6
6
|
* - Returns false if any input is invalid.
|
|
7
|
-
* - Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
|
|
8
7
|
*
|
|
9
8
|
* @param dateTime ISO PlainDateTime string to check
|
|
10
9
|
* @param start ISO PlainDateTime string for the start of the range
|
|
11
10
|
* @param end ISO PlainDateTime string for the end of the range
|
|
12
|
-
* @param options
|
|
11
|
+
* @param options Whether each end of the range counts as inside it
|
|
13
12
|
* @returns boolean indicating whether dateTime is between start and end
|
|
14
13
|
*
|
|
15
14
|
* @example isBetweenDateTime("2024-02-29T12:00:00", "2024-02-01T00:00:00", "2024-02-28T23:59:59") // false
|
|
@@ -21,6 +20,18 @@
|
|
|
21
20
|
* @example isBetweenDateTime("2024-02-29T12:00:00", "2024-02-01T00:00:00", "invalid") // false
|
|
22
21
|
*/
|
|
23
22
|
export declare function isBetweenDateTime(dateTime: string, start: string, end: string, options?: {
|
|
23
|
+
/**
|
|
24
|
+
* Whether `dateTime` equal to `start` counts as inside the range. `false` requires it to
|
|
25
|
+
* be after `start`.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue `true`
|
|
28
|
+
*/
|
|
24
29
|
inclusiveStart?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether `dateTime` equal to `end` counts as inside the range. `false` requires it to be
|
|
32
|
+
* before `end`.
|
|
33
|
+
*
|
|
34
|
+
* @defaultValue `true`
|
|
35
|
+
*/
|
|
25
36
|
inclusiveEnd?: boolean;
|
|
26
37
|
}): boolean;
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { isValidDateTime } from "../validate/index.js";
|
|
4
4
|
import { isOptionsArgument } from "../../internal/isObject.js";
|
|
5
|
+
import { optionOrDefault } from "../../internal/optionOrDefault.js";
|
|
5
6
|
/**
|
|
6
7
|
* Return true when `dateTime` is between `start` and `end` (inclusive by default).
|
|
7
8
|
*
|
|
8
9
|
* - Uses Temporal.PlainDateTime.compare to compare date-times.
|
|
9
10
|
* - Returns false if start > end (invalid range).
|
|
10
11
|
* - Returns false if any input is invalid.
|
|
11
|
-
* - Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
|
|
12
12
|
*
|
|
13
13
|
* @param dateTime ISO PlainDateTime string to check
|
|
14
14
|
* @param start ISO PlainDateTime string for the start of the range
|
|
15
15
|
* @param end ISO PlainDateTime string for the end of the range
|
|
16
|
-
* @param options
|
|
16
|
+
* @param options Whether each end of the range counts as inside it
|
|
17
17
|
* @returns boolean indicating whether dateTime is between start and end
|
|
18
18
|
*
|
|
19
19
|
* @example isBetweenDateTime("2024-02-29T12:00:00", "2024-02-01T00:00:00", "2024-02-28T23:59:59") // false
|
|
@@ -33,8 +33,8 @@ export function isBetweenDateTime(dateTime, start, end, options) {
|
|
|
33
33
|
// reading of it gives `false`: ECMA-402 reads a boolean option through ToBoolean (null → false),
|
|
34
34
|
// and the house rule rejects an invalid member outright — neither yields `true`. So `null`
|
|
35
35
|
// behaves here exactly as `0` and `""` already do.
|
|
36
|
-
const inclusiveStart = options?.inclusiveStart
|
|
37
|
-
const inclusiveEnd = options?.inclusiveEnd
|
|
36
|
+
const inclusiveStart = optionOrDefault(options?.inclusiveStart, true);
|
|
37
|
+
const inclusiveEnd = optionOrDefault(options?.inclusiveEnd, true);
|
|
38
38
|
if (!isValidDateTime(dateTime) ||
|
|
39
39
|
!isValidDateTime(start) ||
|
|
40
40
|
!isValidDateTime(end)) {
|
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
* - Uses Temporal.PlainTime.compare to compare times.
|
|
5
5
|
* - Returns false if start > end (invalid range).
|
|
6
6
|
* - Returns false if any input is invalid.
|
|
7
|
-
* - Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
|
|
8
7
|
* - Note: PlainTime comparison does not account for day overflow.
|
|
9
8
|
*
|
|
10
9
|
* @param time ISO PlainTime string to check
|
|
11
10
|
* @param start ISO PlainTime string for the start of the range
|
|
12
11
|
* @param end ISO PlainTime string for the end of the range
|
|
13
|
-
* @param options
|
|
12
|
+
* @param options Whether each end of the range counts as inside it
|
|
14
13
|
* @returns boolean indicating whether time is between start and end
|
|
15
14
|
*
|
|
16
15
|
* @example isBetweenTime("12:34:56", "12:00:00", "13:00:00") // true
|
|
@@ -23,6 +22,18 @@
|
|
|
23
22
|
* @example isBetweenTime("12:34:56", "12:00:00", "invalid") // false
|
|
24
23
|
*/
|
|
25
24
|
export declare function isBetweenTime(time: string, start: string, end: string, options?: {
|
|
25
|
+
/**
|
|
26
|
+
* Whether `time` equal to `start` counts as inside the range. `false` requires it to
|
|
27
|
+
* be after `start`.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue `true`
|
|
30
|
+
*/
|
|
26
31
|
inclusiveStart?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `time` equal to `end` counts as inside the range. `false` requires it to be
|
|
34
|
+
* before `end`.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue `true`
|
|
37
|
+
*/
|
|
27
38
|
inclusiveEnd?: boolean;
|
|
28
39
|
}): boolean;
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { isValidTime } from "../validate/index.js";
|
|
4
4
|
import { isOptionsArgument } from "../../internal/isObject.js";
|
|
5
|
+
import { optionOrDefault } from "../../internal/optionOrDefault.js";
|
|
5
6
|
/**
|
|
6
7
|
* Return true when `time` is between `start` and `end` (inclusive by default).
|
|
7
8
|
*
|
|
8
9
|
* - Uses Temporal.PlainTime.compare to compare times.
|
|
9
10
|
* - Returns false if start > end (invalid range).
|
|
10
11
|
* - Returns false if any input is invalid.
|
|
11
|
-
* - Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
|
|
12
12
|
* - Note: PlainTime comparison does not account for day overflow.
|
|
13
13
|
*
|
|
14
14
|
* @param time ISO PlainTime string to check
|
|
15
15
|
* @param start ISO PlainTime string for the start of the range
|
|
16
16
|
* @param end ISO PlainTime string for the end of the range
|
|
17
|
-
* @param options
|
|
17
|
+
* @param options Whether each end of the range counts as inside it
|
|
18
18
|
* @returns boolean indicating whether time is between start and end
|
|
19
19
|
*
|
|
20
20
|
* @example isBetweenTime("12:34:56", "12:00:00", "13:00:00") // true
|
|
@@ -35,8 +35,8 @@ export function isBetweenTime(time, start, end, options) {
|
|
|
35
35
|
// reading of it gives `false`: ECMA-402 reads a boolean option through ToBoolean (null → false),
|
|
36
36
|
// and the house rule rejects an invalid member outright — neither yields `true`. So `null`
|
|
37
37
|
// behaves here exactly as `0` and `""` already do.
|
|
38
|
-
const inclusiveStart = options?.inclusiveStart
|
|
39
|
-
const inclusiveEnd = options?.inclusiveEnd
|
|
38
|
+
const inclusiveStart = optionOrDefault(options?.inclusiveStart, true);
|
|
39
|
+
const inclusiveEnd = optionOrDefault(options?.inclusiveEnd, true);
|
|
40
40
|
if (!isValidTime(time) || !isValidTime(start) || !isValidTime(end)) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - `offsetDays` must be an integer; non-integer or non-finite values return false.
|
|
15
15
|
* - Returns false if `value` is invalid or the system timeZone is unavailable.
|
|
16
16
|
*
|
|
17
|
-
* Mapping from date-fns
|
|
17
|
+
* Mapping from date-fns:
|
|
18
18
|
* - `isToday(value)` → `isRelativeDay(value, 0)`
|
|
19
19
|
* - `isYesterday(value)` → `isRelativeDay(value, -1)`
|
|
20
20
|
* - `isTomorrow(value)` → `isRelativeDay(value, 1)`
|
|
@@ -18,7 +18,7 @@ import { areDatesEqual } from "./areDatesEqual.js";
|
|
|
18
18
|
* - `offsetDays` must be an integer; non-integer or non-finite values return false.
|
|
19
19
|
* - Returns false if `value` is invalid or the system timeZone is unavailable.
|
|
20
20
|
*
|
|
21
|
-
* Mapping from date-fns
|
|
21
|
+
* Mapping from date-fns:
|
|
22
22
|
* - `isToday(value)` → `isRelativeDay(value, 0)`
|
|
23
23
|
* - `isYesterday(value)` → `isRelativeDay(value, -1)`
|
|
24
24
|
* - `isTomorrow(value)` → `isRelativeDay(value, 1)`
|
|
@@ -21,7 +21,7 @@ import type { Temporal } from "@js-temporal/polyfill";
|
|
|
21
21
|
* unit, so an invalid locale returns false for `"day"`, `"month"` and `"year"` too.
|
|
22
22
|
* - **Compatibility:** before 1.16.0 an invalid locale was ignored for every unit but `"week"`.
|
|
23
23
|
*
|
|
24
|
-
* Mapping from date-fns
|
|
24
|
+
* Mapping from date-fns:
|
|
25
25
|
* - `isThisWeek(value, options)` → `isThisUnit(value, "week", locale)`
|
|
26
26
|
* - `isThisMonth(value)` → `isThisUnit(value, "month")`
|
|
27
27
|
* - `isThisYear(value)` → `isThisUnit(value, "year")`
|
|
@@ -26,7 +26,7 @@ import { areDatesEqualBy } from "./areDatesEqualBy.js";
|
|
|
26
26
|
* unit, so an invalid locale returns false for `"day"`, `"month"` and `"year"` too.
|
|
27
27
|
* - **Compatibility:** before 1.16.0 an invalid locale was ignored for every unit but `"week"`.
|
|
28
28
|
*
|
|
29
|
-
* Mapping from date-fns
|
|
29
|
+
* Mapping from date-fns:
|
|
30
30
|
* - `isThisWeek(value, options)` → `isThisUnit(value, "week", locale)`
|
|
31
31
|
* - `isThisMonth(value)` → `isThisUnit(value, "month")`
|
|
32
32
|
* - `isThisYear(value)` → `isThisUnit(value, "year")`
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import type { CalendarOptions } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for `formatCalendar`: the date-time the value is compared with, and the style of the
|
|
4
|
+
* time-of-day half.
|
|
5
|
+
*/
|
|
2
6
|
export interface FormatCalendarOptions extends CalendarOptions {
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
* "
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* The length of the time-of-day part, as the `timeStyle` of `Intl.DateTimeFormat`. "long" and
|
|
9
|
+
* "full" are not offered: they differ from "medium" only by a `timeZoneName`, and a plain value
|
|
10
|
+
* has no zone. Passed anyway (from untyped code), they format as "medium" — Temporal's
|
|
11
|
+
* PlainDateTime format drops `timeZoneName` (AdjustDateTimeStyleFormat).
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue `"short"`
|
|
9
14
|
*/
|
|
10
15
|
timeStyle?: "short" | "medium";
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* Format a plain date-time as a relative day label plus time-of-day, e.g.
|
|
14
|
-
* "Tomorrow at 2:30 PM"
|
|
15
|
-
*
|
|
16
|
-
*
|
|
19
|
+
* "Tomorrow at 2:30 PM". The `formatRelativeDateTime` family does not
|
|
20
|
+
* cover this: it renders "in 1 day", an elapsed-time phrase, not a day
|
|
21
|
+
* label + clock time.
|
|
17
22
|
*
|
|
18
23
|
* - Within `±6` days of `reference` (default: now), renders `<day label>`
|
|
19
24
|
* joined to the localized time using the locale's own connector — never a
|
|
@@ -21,15 +26,17 @@ export interface FormatCalendarOptions extends CalendarOptions {
|
|
|
21
26
|
* (`numeric: "auto"`), so it reads "Today"/"Tomorrow"/"Yesterday" near
|
|
22
27
|
* the boundary and "in N days"/"N days ago" further out, all locale-native.
|
|
23
28
|
* - Beyond `±6` days, falls back to an absolute `dateStyle: "long"` +
|
|
24
|
-
* `timeStyle` string with no relative wording
|
|
25
|
-
*
|
|
29
|
+
* `timeStyle` string with no relative wording. The one-week limit is
|
|
30
|
+
* GMT's own rule, not a standard's: from 7 days out a date is easier to
|
|
31
|
+
* place than a day count.
|
|
32
|
+
* - Comparison: Moment's `.calendar()` switches to a date at the same
|
|
33
|
+
* distance (its `sameElse` case); its wording inside the week differs.
|
|
26
34
|
* - The connector between the day label and the time is read from CLDR's
|
|
27
35
|
* own combined date+time pattern for the locale (see
|
|
28
36
|
* `internal/joinDateTimeConnector.ts`), not hardcoded — this is what lets
|
|
29
37
|
* `formatCalendar` avoid the i18n objection that excludes a token
|
|
30
|
-
* formatter
|
|
31
|
-
* - The time never carries a zone name: a plain value has none.
|
|
32
|
-
* `"full"` (outside the type) formats as `"medium"`.
|
|
38
|
+
* formatter.
|
|
39
|
+
* - The time never carries a zone name: a plain value has none.
|
|
33
40
|
* - Use `formatCalendar` for user-facing schedules ("Tomorrow at 2:30 PM");
|
|
34
41
|
* use `formatRelativeDateTime` for elapsed-time displays ("in 1 day").
|
|
35
42
|
* - `options` must be an object or omitted: `null` or any other primitive returns `""`, as
|
|
@@ -37,7 +44,7 @@ export interface FormatCalendarOptions extends CalendarOptions {
|
|
|
37
44
|
*
|
|
38
45
|
* @param value ISO PlainDateTime string to format
|
|
39
46
|
* @param locale optional: BCP 47 locale tag, or a preference list of tags (ECMA-402)
|
|
40
|
-
* @param options
|
|
47
|
+
* @param options What the value is compared with and how the time is written
|
|
41
48
|
* @returns the formatted calendar string, or "" on invalid input
|
|
42
49
|
*
|
|
43
50
|
* @example formatCalendar("2026-03-16T14:30:00", "en-US", { reference: "2026-03-15T09:00:00" }) // "tomorrow at 2:30 PM"
|
|
@@ -3,15 +3,16 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
3
3
|
import { joinDateTimeConnector, normalizeDateTime } from "../../internal/index.js";
|
|
4
4
|
import { plainTimeStyle } from "../../internal/plainFormatOptions.js";
|
|
5
5
|
import { isValidDateTime } from "../validate/index.js";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
import { optionOrDefault } from "../../internal/optionOrDefault.js";
|
|
7
|
+
// GMT's own rule, not a standard's: the relative day label is kept for distances
|
|
8
|
+
// under one week (up to 6 calendar days either way). From 7 days out the phrase
|
|
9
|
+
// is an absolute date, which is easier to place than a day count.
|
|
9
10
|
const ABS_DAY_THRESHOLD = 6;
|
|
10
11
|
/**
|
|
11
12
|
* Format a plain date-time as a relative day label plus time-of-day, e.g.
|
|
12
|
-
* "Tomorrow at 2:30 PM"
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* "Tomorrow at 2:30 PM". The `formatRelativeDateTime` family does not
|
|
14
|
+
* cover this: it renders "in 1 day", an elapsed-time phrase, not a day
|
|
15
|
+
* label + clock time.
|
|
15
16
|
*
|
|
16
17
|
* - Within `±6` days of `reference` (default: now), renders `<day label>`
|
|
17
18
|
* joined to the localized time using the locale's own connector — never a
|
|
@@ -19,15 +20,17 @@ const ABS_DAY_THRESHOLD = 6;
|
|
|
19
20
|
* (`numeric: "auto"`), so it reads "Today"/"Tomorrow"/"Yesterday" near
|
|
20
21
|
* the boundary and "in N days"/"N days ago" further out, all locale-native.
|
|
21
22
|
* - Beyond `±6` days, falls back to an absolute `dateStyle: "long"` +
|
|
22
|
-
* `timeStyle` string with no relative wording
|
|
23
|
-
*
|
|
23
|
+
* `timeStyle` string with no relative wording. The one-week limit is
|
|
24
|
+
* GMT's own rule, not a standard's: from 7 days out a date is easier to
|
|
25
|
+
* place than a day count.
|
|
26
|
+
* - Comparison: Moment's `.calendar()` switches to a date at the same
|
|
27
|
+
* distance (its `sameElse` case); its wording inside the week differs.
|
|
24
28
|
* - The connector between the day label and the time is read from CLDR's
|
|
25
29
|
* own combined date+time pattern for the locale (see
|
|
26
30
|
* `internal/joinDateTimeConnector.ts`), not hardcoded — this is what lets
|
|
27
31
|
* `formatCalendar` avoid the i18n objection that excludes a token
|
|
28
|
-
* formatter
|
|
29
|
-
* - The time never carries a zone name: a plain value has none.
|
|
30
|
-
* `"full"` (outside the type) formats as `"medium"`.
|
|
32
|
+
* formatter.
|
|
33
|
+
* - The time never carries a zone name: a plain value has none.
|
|
31
34
|
* - Use `formatCalendar` for user-facing schedules ("Tomorrow at 2:30 PM");
|
|
32
35
|
* use `formatRelativeDateTime` for elapsed-time displays ("in 1 day").
|
|
33
36
|
* - `options` must be an object or omitted: `null` or any other primitive returns `""`, as
|
|
@@ -35,7 +38,7 @@ const ABS_DAY_THRESHOLD = 6;
|
|
|
35
38
|
*
|
|
36
39
|
* @param value ISO PlainDateTime string to format
|
|
37
40
|
* @param locale optional: BCP 47 locale tag, or a preference list of tags (ECMA-402)
|
|
38
|
-
* @param options
|
|
41
|
+
* @param options What the value is compared with and how the time is written
|
|
39
42
|
* @returns the formatted calendar string, or "" on invalid input
|
|
40
43
|
*
|
|
41
44
|
* @example formatCalendar("2026-03-16T14:30:00", "en-US", { reference: "2026-03-15T09:00:00" }) // "tomorrow at 2:30 PM"
|
|
@@ -52,18 +55,20 @@ export function formatCalendar(value, locale, options = {}) {
|
|
|
52
55
|
return "";
|
|
53
56
|
if (!isValidDateTime(value))
|
|
54
57
|
return "";
|
|
55
|
-
|
|
58
|
+
// Each option is read once (GetOption).
|
|
59
|
+
const referenceOption = options.reference;
|
|
60
|
+
if (referenceOption !== undefined && !isValidDateTime(referenceOption))
|
|
56
61
|
return "";
|
|
57
62
|
try {
|
|
58
63
|
const target = Temporal.PlainDateTime.from(value);
|
|
59
|
-
const reference =
|
|
60
|
-
? Temporal.PlainDateTime.from(
|
|
64
|
+
const reference = referenceOption
|
|
65
|
+
? Temporal.PlainDateTime.from(referenceOption)
|
|
61
66
|
: Temporal.Now.plainDateTimeISO();
|
|
62
67
|
const diffDays = target.toPlainDate().since(reference.toPlainDate()).days;
|
|
63
68
|
// "long"/"full" are outside the type but reachable from JS; their zone
|
|
64
69
|
// name would describe the UTC anchor, not the value. Temporal's
|
|
65
70
|
// PlainDateTime format drops timeZoneName (AdjustDateTimeStyleFormat).
|
|
66
|
-
const timeStyle = plainTimeStyle(options.timeStyle
|
|
71
|
+
const timeStyle = plainTimeStyle(optionOrDefault(options.timeStyle, "short"));
|
|
67
72
|
// Plain values carry no timezone. UTC is an arbitrary but stable anchor
|
|
68
73
|
// for reusing Intl's part-level formatting — any fixed zone reproduces
|
|
69
74
|
// the same wall-clock fields since there's no real zone to get wrong.
|
|
@@ -2,6 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { normalizeDateTime } from "../../internal/index.js";
|
|
3
3
|
import { plainDateFormatOptions } from "../../internal/plainFormatOptions.js";
|
|
4
4
|
import { isValidDate } from "../validate/index.js";
|
|
5
|
+
import { readDateTimeFormatOptions } from "../../internal/readDateTimeFormatOptions.js";
|
|
5
6
|
/**
|
|
6
7
|
* Return a localized string for a PlainDate ISO input using Intl options.
|
|
7
8
|
*
|
|
@@ -45,12 +46,13 @@ export function formatDate(value, locale, options) {
|
|
|
45
46
|
// (CreateDateTimeFormat ~date~, ~date~), so the requested fields and
|
|
46
47
|
// widths are kept. Constructing with the caller's options first surfaces
|
|
47
48
|
// the TypeError or RangeError Intl.DateTimeFormat raises for invalid ones.
|
|
48
|
-
|
|
49
|
+
const read = readDateTimeFormatOptions(options);
|
|
50
|
+
new Intl.DateTimeFormat(locale, read);
|
|
49
51
|
// CreateDateTimeFormat: required ~date~ with a timeStyle is a TypeError.
|
|
50
|
-
if (
|
|
52
|
+
if (read.timeStyle !== undefined) {
|
|
51
53
|
return "";
|
|
52
54
|
}
|
|
53
|
-
const resolved = plainDateFormatOptions(
|
|
55
|
+
const resolved = plainDateFormatOptions(read);
|
|
54
56
|
if (resolved === null) {
|
|
55
57
|
return "";
|
|
56
58
|
}
|
|
@@ -2,6 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { normalizeDateTime } from "../../internal/index.js";
|
|
3
3
|
import { plainDateFormatOptions } from "../../internal/plainFormatOptions.js";
|
|
4
4
|
import { isValidDate } from "../validate/index.js";
|
|
5
|
+
import { readDateTimeFormatOptions } from "../../internal/readDateTimeFormatOptions.js";
|
|
5
6
|
/**
|
|
6
7
|
* Format a plain date range using the Temporal Intl.DateTimeFormat formatRange API.
|
|
7
8
|
*
|
|
@@ -43,8 +44,9 @@ export function formatDateRange(start, end, locale, options) {
|
|
|
43
44
|
// (GetDateTimeFormat ~date~, ~date~, ~relevant~). Constructing with the
|
|
44
45
|
// caller's options first surfaces the TypeError or RangeError
|
|
45
46
|
// Intl.DateTimeFormat raises for invalid ones.
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const read = readDateTimeFormatOptions(options);
|
|
48
|
+
new Intl.DateTimeFormat(locale, read);
|
|
49
|
+
const resolved = plainDateFormatOptions(read);
|
|
48
50
|
if (resolved === null) {
|
|
49
51
|
return "";
|
|
50
52
|
}
|
|
@@ -2,6 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { normalizeDateTime } from "../../internal/index.js";
|
|
3
3
|
import { plainDateTimeFormatOptions } from "../../internal/plainFormatOptions.js";
|
|
4
4
|
import { isValidDateTime } from "../validate/index.js";
|
|
5
|
+
import { readDateTimeFormatOptions } from "../../internal/readDateTimeFormatOptions.js";
|
|
5
6
|
/**
|
|
6
7
|
* Return a localized string for a PlainDateTime ISO input using Intl options.
|
|
7
8
|
*
|
|
@@ -47,9 +48,10 @@ export function formatDateTime(value, locale, options) {
|
|
|
47
48
|
// and style widths are kept. Constructing with the caller's options first
|
|
48
49
|
// surfaces the TypeError or RangeError Intl.DateTimeFormat raises for
|
|
49
50
|
// invalid ones.
|
|
50
|
-
|
|
51
|
+
const read = readDateTimeFormatOptions(options);
|
|
52
|
+
new Intl.DateTimeFormat(locale, read);
|
|
51
53
|
const epochMilliseconds = Temporal.PlainDateTime.from(value).toZonedDateTime("UTC").epochMilliseconds;
|
|
52
|
-
return normalizeDateTime(new Intl.DateTimeFormat(locale, plainDateTimeFormatOptions(
|
|
54
|
+
return normalizeDateTime(new Intl.DateTimeFormat(locale, plainDateTimeFormatOptions(read)).format(epochMilliseconds));
|
|
53
55
|
}
|
|
54
56
|
catch {
|
|
55
57
|
return "";
|
|
@@ -2,6 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { normalizeDateTime } from "../../internal/index.js";
|
|
3
3
|
import { plainDateTimeFormatOptions } from "../../internal/plainFormatOptions.js";
|
|
4
4
|
import { isValidDateTime } from "../validate/index.js";
|
|
5
|
+
import { readDateTimeFormatOptions } from "../../internal/readDateTimeFormatOptions.js";
|
|
5
6
|
/**
|
|
6
7
|
* Format a plain datetime range using the Temporal Intl.DateTimeFormat formatRange API.
|
|
7
8
|
*
|
|
@@ -46,8 +47,9 @@ export function formatDateTimeRange(start, end, locale, options) {
|
|
|
46
47
|
// (GetDateTimeFormat ~any~, ~all~, ~relevant~). Constructing with the
|
|
47
48
|
// caller's options first surfaces the TypeError or RangeError
|
|
48
49
|
// Intl.DateTimeFormat raises for invalid ones.
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const read = readDateTimeFormatOptions(options);
|
|
51
|
+
new Intl.DateTimeFormat(locale, read);
|
|
52
|
+
const out = new Intl.DateTimeFormat(locale, plainDateTimeFormatOptions(read)).formatRange(Temporal.PlainDateTime.from(start).toZonedDateTime("UTC")
|
|
51
53
|
.epochMilliseconds, Temporal.PlainDateTime.from(end).toZonedDateTime("UTC").epochMilliseconds);
|
|
52
54
|
return normalizeDateTime(out);
|
|
53
55
|
}
|
|
@@ -5,8 +5,7 @@ import type { DateTimeFormatOptions } from "../../types/index.js";
|
|
|
5
5
|
* - This is GMT's substitute for a token formatter (Luxon `toFormat`, date-fns
|
|
6
6
|
* `format`). A token pattern hard-codes field order and ships US ordering to
|
|
7
7
|
* every locale; `formatToParts` gives the caller full control over presentation
|
|
8
|
-
* while the *locale* keeps control of order.
|
|
9
|
-
* `context/roadmap/issues/J.md`.
|
|
8
|
+
* while the *locale* keeps control of order.
|
|
10
9
|
* - Each part is `{ type, value }` where `type` can be:
|
|
11
10
|
* `"era"`, `"year"`, `"relatedYear"`, `"yearName"`, `"month"`, `"day"`, `"weekday"`,
|
|
12
11
|
* `"hour"`, `"minute"`, `"second"`, `"fractionalSecond"`, `"dayPeriod"`, `"literal"`.
|
|
@@ -24,8 +23,11 @@ import type { DateTimeFormatOptions } from "../../types/index.js";
|
|
|
24
23
|
* zone field): a `timeZoneName` option is ignored, and a `"long"`/`"full"` `timeStyle` keeps its
|
|
25
24
|
* hour, minute and second and drops the zone, formatting as the locale's `"medium"` time. As in
|
|
26
25
|
* `Intl.DateTimeFormat`, `timeZoneName` together with `dateStyle`/`timeStyle` yields `[]`.
|
|
27
|
-
* -
|
|
28
|
-
*
|
|
26
|
+
* - The literal before the day period depends on the runtime. CLDR 42 (ICU 72) put U+202F NARROW
|
|
27
|
+
* NO-BREAK SPACE there for `en-US`; Node 22 and 24 return it in the parts, and Node 26 returns
|
|
28
|
+
* an ordinary space (U+0020) instead. Both were checked on those runtimes. The examples show the
|
|
29
|
+
* Node 22 and 24 form, written as `"\u202f"` so the difference is visible. Treat the two
|
|
30
|
+
* characters as equal when you compare parts.
|
|
29
31
|
* - Returns `[]` for invalid input.
|
|
30
32
|
* - **Compatibility:** before 1.16.0 a call with no field options returned only the date parts.
|
|
31
33
|
* Pass `{ year: "numeric", month: "numeric", day: "numeric" }` to keep that output.
|
|
@@ -50,6 +52,15 @@ import type { DateTimeFormatOptions } from "../../types/index.js";
|
|
|
50
52
|
* @example formatDateTimeToParts("2024-02-03T14:30:45", ["fr-FR", "en-US"], { dateStyle: "medium", timeStyle: "short" }) // parts of "3 févr. 2024, 14:30"
|
|
51
53
|
*/
|
|
52
54
|
export declare function formatDateTimeToParts(value: string, locale?: string | string[], options?: DateTimeFormatOptions): Array<{
|
|
55
|
+
/**
|
|
56
|
+
* The kind of part, named as ECMA-402 `Intl.DateTimeFormat.prototype.formatToParts` names it: a
|
|
57
|
+
* field such as `"year"`, `"month"` or `"day"`, or `"literal"` for the separator text between
|
|
58
|
+
* fields.
|
|
59
|
+
*/
|
|
53
60
|
type: string;
|
|
61
|
+
/**
|
|
62
|
+
* The text of the part in the requested locale, exactly as the formatter wrote it. Joining every
|
|
63
|
+
* `value` in array order gives the whole formatted text.
|
|
64
|
+
*/
|
|
54
65
|
value: string;
|
|
55
66
|
}>;
|