@northguild/gmt 1.14.2
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/LICENSE +21 -0
- package/README.md +1626 -0
- package/dist/duration/calculate/absDuration.d.ts +20 -0
- package/dist/duration/calculate/absDuration.js +32 -0
- package/dist/duration/calculate/addDuration.d.ts +20 -0
- package/dist/duration/calculate/addDuration.js +32 -0
- package/dist/duration/calculate/durationAs.d.ts +38 -0
- package/dist/duration/calculate/durationAs.js +52 -0
- package/dist/duration/calculate/getDurationSign.d.ts +22 -0
- package/dist/duration/calculate/getDurationSign.js +34 -0
- package/dist/duration/calculate/getDurationUnit.d.ts +31 -0
- package/dist/duration/calculate/getDurationUnit.js +43 -0
- package/dist/duration/calculate/index.d.ts +7 -0
- package/dist/duration/calculate/index.js +7 -0
- package/dist/duration/calculate/negateDuration.d.ts +20 -0
- package/dist/duration/calculate/negateDuration.js +32 -0
- package/dist/duration/calculate/subtractDuration.d.ts +21 -0
- package/dist/duration/calculate/subtractDuration.js +33 -0
- package/dist/duration/compare/compareDurations.d.ts +37 -0
- package/dist/duration/compare/compareDurations.js +49 -0
- package/dist/duration/compare/index.d.ts +1 -0
- package/dist/duration/compare/index.js +1 -0
- package/dist/duration/format/formatDuration.d.ts +37 -0
- package/dist/duration/format/formatDuration.js +93 -0
- package/dist/duration/format/index.d.ts +1 -0
- package/dist/duration/format/index.js +1 -0
- package/dist/duration/index.d.ts +6 -0
- package/dist/duration/index.js +6 -0
- package/dist/duration/normalize/index.d.ts +1 -0
- package/dist/duration/normalize/index.js +1 -0
- package/dist/duration/normalize/normalizeDuration.d.ts +36 -0
- package/dist/duration/normalize/normalizeDuration.js +49 -0
- package/dist/duration/parse/index.d.ts +1 -0
- package/dist/duration/parse/index.js +1 -0
- package/dist/duration/parse/parseDuration.d.ts +24 -0
- package/dist/duration/parse/parseDuration.js +35 -0
- package/dist/duration/validate/index.d.ts +1 -0
- package/dist/duration/validate/index.js +1 -0
- package/dist/duration/validate/isValidDuration.d.ts +16 -0
- package/dist/duration/validate/isValidDuration.js +28 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/internal/adjustZonedBusinessDays.d.ts +1 -0
- package/dist/internal/adjustZonedBusinessDays.js +16 -0
- package/dist/internal/advanceBusinessDays.d.ts +2 -0
- package/dist/internal/advanceBusinessDays.js +15 -0
- package/dist/internal/advanceToWeekday.d.ts +12 -0
- package/dist/internal/advanceToWeekday.js +24 -0
- package/dist/internal/calendarDatePairPolicy.d.ts +25 -0
- package/dist/internal/calendarDatePairPolicy.js +33 -0
- package/dist/internal/calendarDateString.d.ts +65 -0
- package/dist/internal/calendarDateString.js +103 -0
- package/dist/internal/calendarSystemIds.d.ts +4 -0
- package/dist/internal/calendarSystemIds.js +55 -0
- package/dist/internal/calendarValueOfDate.d.ts +22 -0
- package/dist/internal/calendarValueOfDate.js +41 -0
- package/dist/internal/calendarValueOfZoned.d.ts +38 -0
- package/dist/internal/calendarValueOfZoned.js +58 -0
- package/dist/internal/calendarZonedPairPolicy.d.ts +31 -0
- package/dist/internal/calendarZonedPairPolicy.js +39 -0
- package/dist/internal/calendarZonedString.d.ts +77 -0
- package/dist/internal/calendarZonedString.js +120 -0
- package/dist/internal/cycleFieldValue.d.ts +30 -0
- package/dist/internal/cycleFieldValue.js +48 -0
- package/dist/internal/dateCycleFieldBounds.d.ts +25 -0
- package/dist/internal/dateCycleFieldBounds.js +27 -0
- package/dist/internal/dateTimeUnitHelpers.d.ts +27 -0
- package/dist/internal/dateTimeUnitHelpers.js +50 -0
- package/dist/internal/dateUnitHelpers.d.ts +23 -0
- package/dist/internal/dateUnitHelpers.js +46 -0
- package/dist/internal/durationUntilString.d.ts +17 -0
- package/dist/internal/durationUntilString.js +13 -0
- package/dist/internal/englishCalendarNames.d.ts +2 -0
- package/dist/internal/englishCalendarNames.js +30 -0
- package/dist/internal/ethiopicFamilyCalendar.d.ts +47 -0
- package/dist/internal/ethiopicFamilyCalendar.js +136 -0
- package/dist/internal/formatDateInCalendar.d.ts +47 -0
- package/dist/internal/formatDateInCalendar.js +54 -0
- package/dist/internal/getLocaleFirstDayOfWeek.d.ts +11 -0
- package/dist/internal/getLocaleFirstDayOfWeek.js +26 -0
- package/dist/internal/getLocaleMinimalDaysInFirstWeek.d.ts +20 -0
- package/dist/internal/getLocaleMinimalDaysInFirstWeek.js +31 -0
- package/dist/internal/getLocaleWeekYearBounds.d.ts +19 -0
- package/dist/internal/getLocaleWeekYearBounds.js +44 -0
- package/dist/internal/getLocaleWeekendDays.d.ts +22 -0
- package/dist/internal/getLocaleWeekendDays.js +20 -0
- package/dist/internal/hasCalendarAnnotation.d.ts +27 -0
- package/dist/internal/hasCalendarAnnotation.js +29 -0
- package/dist/internal/index.d.ts +34 -0
- package/dist/internal/index.js +34 -0
- package/dist/internal/intervalCountHelpers.d.ts +26 -0
- package/dist/internal/intervalCountHelpers.js +62 -0
- package/dist/internal/isValidAmount.d.ts +9 -0
- package/dist/internal/isValidAmount.js +11 -0
- package/dist/internal/isValidDayOfWeek.d.ts +11 -0
- package/dist/internal/isValidDayOfWeek.js +13 -0
- package/dist/internal/joinDateTimeConnector.d.ts +37 -0
- package/dist/internal/joinDateTimeConnector.js +85 -0
- package/dist/internal/monthGridWeekRow.d.ts +12 -0
- package/dist/internal/monthGridWeekRow.js +14 -0
- package/dist/internal/normalizeDateTime.d.ts +14 -0
- package/dist/internal/normalizeDateTime.js +34 -0
- package/dist/internal/normalizeTimeZone.d.ts +14 -0
- package/dist/internal/normalizeTimeZone.js +22 -0
- package/dist/internal/patternToken.d.ts +45 -0
- package/dist/internal/patternToken.js +385 -0
- package/dist/internal/resolveDateTimeUnit.d.ts +11 -0
- package/dist/internal/resolveDateTimeUnit.js +23 -0
- package/dist/internal/resolveDurationRelativeTo.d.ts +29 -0
- package/dist/internal/resolveDurationRelativeTo.js +35 -0
- package/dist/internal/resolveDurationUnit.d.ts +10 -0
- package/dist/internal/resolveDurationUnit.js +23 -0
- package/dist/internal/resolveOverflow.d.ts +10 -0
- package/dist/internal/resolveOverflow.js +11 -0
- package/dist/internal/resolveRelativeRounding.d.ts +19 -0
- package/dist/internal/resolveRelativeRounding.js +20 -0
- package/dist/internal/resolveUnixTimeZone.d.ts +20 -0
- package/dist/internal/resolveUnixTimeZone.js +30 -0
- package/dist/internal/timeCycleFieldBounds.d.ts +16 -0
- package/dist/internal/timeCycleFieldBounds.js +24 -0
- package/dist/internal/toInstantFromUtc.d.ts +2 -0
- package/dist/internal/toInstantFromUtc.js +11 -0
- package/dist/plain/calculate/addBusinessDays.d.ts +17 -0
- package/dist/plain/calculate/addBusinessDays.js +35 -0
- package/dist/plain/calculate/addDate.d.ts +35 -0
- package/dist/plain/calculate/addDate.js +55 -0
- package/dist/plain/calculate/addDateTime.d.ts +22 -0
- package/dist/plain/calculate/addDateTime.js +38 -0
- package/dist/plain/calculate/addTime.d.ts +22 -0
- package/dist/plain/calculate/addTime.js +38 -0
- package/dist/plain/calculate/clampDate.d.ts +20 -0
- package/dist/plain/calculate/clampDate.js +46 -0
- package/dist/plain/calculate/closestDateTo.d.ts +18 -0
- package/dist/plain/calculate/closestDateTo.js +43 -0
- package/dist/plain/calculate/cycleDate.d.ts +44 -0
- package/dist/plain/calculate/cycleDate.js +56 -0
- package/dist/plain/calculate/cycleDateTime.d.ts +38 -0
- package/dist/plain/calculate/cycleDateTime.js +52 -0
- package/dist/plain/calculate/cycleTime.d.ts +38 -0
- package/dist/plain/calculate/cycleTime.js +50 -0
- package/dist/plain/calculate/diffDate.d.ts +32 -0
- package/dist/plain/calculate/diffDate.js +64 -0
- package/dist/plain/calculate/diffDateAsDuration.d.ts +36 -0
- package/dist/plain/calculate/diffDateAsDuration.js +49 -0
- package/dist/plain/calculate/diffDateTime.d.ts +25 -0
- package/dist/plain/calculate/diffDateTime.js +57 -0
- package/dist/plain/calculate/diffDateTimeAsDuration.d.ts +33 -0
- package/dist/plain/calculate/diffDateTimeAsDuration.js +48 -0
- package/dist/plain/calculate/diffTime.d.ts +25 -0
- package/dist/plain/calculate/diffTime.js +56 -0
- package/dist/plain/calculate/endOfDate.d.ts +17 -0
- package/dist/plain/calculate/endOfDate.js +51 -0
- package/dist/plain/calculate/endOfDateTime.d.ts +19 -0
- package/dist/plain/calculate/endOfDateTime.js +138 -0
- package/dist/plain/calculate/endOfQuarterForDate.d.ts +17 -0
- package/dist/plain/calculate/endOfQuarterForDate.js +34 -0
- package/dist/plain/calculate/endOfQuarterForDateTime.d.ts +15 -0
- package/dist/plain/calculate/endOfQuarterForDateTime.js +48 -0
- package/dist/plain/calculate/endOfTime.d.ts +20 -0
- package/dist/plain/calculate/endOfTime.js +91 -0
- package/dist/plain/calculate/getDayOfYear.d.ts +16 -0
- package/dist/plain/calculate/getDayOfYear.js +28 -0
- package/dist/plain/calculate/getDaysInMonth.d.ts +16 -0
- package/dist/plain/calculate/getDaysInMonth.js +28 -0
- package/dist/plain/calculate/getDaysInYear.d.ts +14 -0
- package/dist/plain/calculate/getDaysInYear.js +26 -0
- package/dist/plain/calculate/getLargestDateDurationUnit.d.ts +16 -0
- package/dist/plain/calculate/getLargestDateDurationUnit.js +24 -0
- package/dist/plain/calculate/getLargestDateTimeDurationUnit.d.ts +16 -0
- package/dist/plain/calculate/getLargestDateTimeDurationUnit.js +35 -0
- package/dist/plain/calculate/getLargestTimeDurationUnit.d.ts +16 -0
- package/dist/plain/calculate/getLargestTimeDurationUnit.js +31 -0
- package/dist/plain/calculate/getLocaleDayOfWeek.d.ts +20 -0
- package/dist/plain/calculate/getLocaleDayOfWeek.js +36 -0
- package/dist/plain/calculate/getLocaleEndOfWeek.d.ts +23 -0
- package/dist/plain/calculate/getLocaleEndOfWeek.js +40 -0
- package/dist/plain/calculate/getLocaleStartOfWeek.d.ts +23 -0
- package/dist/plain/calculate/getLocaleStartOfWeek.js +40 -0
- package/dist/plain/calculate/getLocaleWeekYear.d.ts +28 -0
- package/dist/plain/calculate/getLocaleWeekYear.js +45 -0
- package/dist/plain/calculate/getQuarterForDate.d.ts +17 -0
- package/dist/plain/calculate/getQuarterForDate.js +30 -0
- package/dist/plain/calculate/getQuarterForDateTime.d.ts +17 -0
- package/dist/plain/calculate/getQuarterForDateTime.js +30 -0
- package/dist/plain/calculate/getWeekNumber.d.ts +17 -0
- package/dist/plain/calculate/getWeekNumber.js +39 -0
- package/dist/plain/calculate/getWeekOfMonth.d.ts +26 -0
- package/dist/plain/calculate/getWeekOfMonth.js +43 -0
- package/dist/plain/calculate/getWeekYear.d.ts +21 -0
- package/dist/plain/calculate/getWeekYear.js +33 -0
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.d.ts +24 -0
- package/dist/plain/calculate/getWeeksInLocaleWeekYear.js +43 -0
- package/dist/plain/calculate/getWeeksInMonth.d.ts +23 -0
- package/dist/plain/calculate/getWeeksInMonth.js +40 -0
- package/dist/plain/calculate/getWeeksInYear.d.ts +23 -0
- package/dist/plain/calculate/getWeeksInYear.js +43 -0
- package/dist/plain/calculate/index.d.ts +64 -0
- package/dist/plain/calculate/index.js +64 -0
- package/dist/plain/calculate/maxDate.d.ts +13 -0
- package/dist/plain/calculate/maxDate.js +33 -0
- package/dist/plain/calculate/maxDateTime.d.ts +13 -0
- package/dist/plain/calculate/maxDateTime.js +33 -0
- package/dist/plain/calculate/maxTime.d.ts +13 -0
- package/dist/plain/calculate/maxTime.js +33 -0
- package/dist/plain/calculate/minDate.d.ts +13 -0
- package/dist/plain/calculate/minDate.js +33 -0
- package/dist/plain/calculate/minDateTime.d.ts +13 -0
- package/dist/plain/calculate/minDateTime.js +33 -0
- package/dist/plain/calculate/minTime.d.ts +13 -0
- package/dist/plain/calculate/minTime.js +33 -0
- package/dist/plain/calculate/nextWeekday.d.ts +36 -0
- package/dist/plain/calculate/nextWeekday.js +47 -0
- package/dist/plain/calculate/previousWeekday.d.ts +36 -0
- package/dist/plain/calculate/previousWeekday.js +47 -0
- package/dist/plain/calculate/roundDate.d.ts +26 -0
- package/dist/plain/calculate/roundDate.js +72 -0
- package/dist/plain/calculate/roundDateTime.d.ts +26 -0
- package/dist/plain/calculate/roundDateTime.js +98 -0
- package/dist/plain/calculate/roundTime.d.ts +22 -0
- package/dist/plain/calculate/roundTime.js +42 -0
- package/dist/plain/calculate/setDate.d.ts +32 -0
- package/dist/plain/calculate/setDate.js +47 -0
- package/dist/plain/calculate/setDateTime.d.ts +31 -0
- package/dist/plain/calculate/setDateTime.js +46 -0
- package/dist/plain/calculate/setTime.d.ts +31 -0
- package/dist/plain/calculate/setTime.js +46 -0
- package/dist/plain/calculate/sortDateTimes.d.ts +14 -0
- package/dist/plain/calculate/sortDateTimes.js +33 -0
- package/dist/plain/calculate/sortDates.d.ts +14 -0
- package/dist/plain/calculate/sortDates.js +33 -0
- package/dist/plain/calculate/sortTimes.d.ts +14 -0
- package/dist/plain/calculate/sortTimes.js +33 -0
- package/dist/plain/calculate/startOfDate.d.ts +17 -0
- package/dist/plain/calculate/startOfDate.js +50 -0
- package/dist/plain/calculate/startOfDateTime.d.ts +19 -0
- package/dist/plain/calculate/startOfDateTime.js +85 -0
- package/dist/plain/calculate/startOfQuarterForDate.d.ts +17 -0
- package/dist/plain/calculate/startOfQuarterForDate.js +32 -0
- package/dist/plain/calculate/startOfQuarterForDateTime.d.ts +15 -0
- package/dist/plain/calculate/startOfQuarterForDateTime.js +32 -0
- package/dist/plain/calculate/startOfTime.d.ts +20 -0
- package/dist/plain/calculate/startOfTime.js +69 -0
- package/dist/plain/calculate/subtractBusinessDays.d.ts +18 -0
- package/dist/plain/calculate/subtractBusinessDays.js +36 -0
- package/dist/plain/calculate/subtractDate.d.ts +27 -0
- package/dist/plain/calculate/subtractDate.js +47 -0
- package/dist/plain/calculate/subtractDateTime.d.ts +22 -0
- package/dist/plain/calculate/subtractDateTime.js +38 -0
- package/dist/plain/calculate/subtractTime.d.ts +22 -0
- package/dist/plain/calculate/subtractTime.js +38 -0
- package/dist/plain/calculate/weekOfYear.d.ts +30 -0
- package/dist/plain/calculate/weekOfYear.js +57 -0
- package/dist/plain/chop/chopDate.d.ts +13 -0
- package/dist/plain/chop/chopDate.js +24 -0
- package/dist/plain/chop/chopMilliseconds.d.ts +15 -0
- package/dist/plain/chop/chopMilliseconds.js +34 -0
- package/dist/plain/chop/chopSeconds.d.ts +15 -0
- package/dist/plain/chop/chopSeconds.js +34 -0
- package/dist/plain/chop/chopTime.d.ts +13 -0
- package/dist/plain/chop/chopTime.js +24 -0
- package/dist/plain/chop/index.d.ts +5 -0
- package/dist/plain/chop/index.js +5 -0
- package/dist/plain/compare/areDateTimesEqual.d.ts +15 -0
- package/dist/plain/compare/areDateTimesEqual.js +37 -0
- package/dist/plain/compare/areDateTimesEqualBy.d.ts +37 -0
- package/dist/plain/compare/areDateTimesEqualBy.js +49 -0
- package/dist/plain/compare/areDatesEqual.d.ts +17 -0
- package/dist/plain/compare/areDatesEqual.js +33 -0
- package/dist/plain/compare/areDatesEqualBy.d.ts +34 -0
- package/dist/plain/compare/areDatesEqualBy.js +54 -0
- package/dist/plain/compare/areTimesEqual.d.ts +18 -0
- package/dist/plain/compare/areTimesEqual.js +37 -0
- package/dist/plain/compare/index.d.ts +20 -0
- package/dist/plain/compare/index.js +20 -0
- package/dist/plain/compare/isAfterDate.d.ts +16 -0
- package/dist/plain/compare/isAfterDate.js +28 -0
- package/dist/plain/compare/isAfterDateTime.d.ts +17 -0
- package/dist/plain/compare/isAfterDateTime.js +29 -0
- package/dist/plain/compare/isAfterTime.d.ts +17 -0
- package/dist/plain/compare/isAfterTime.js +29 -0
- package/dist/plain/compare/isBeforeDate.d.ts +17 -0
- package/dist/plain/compare/isBeforeDate.js +29 -0
- package/dist/plain/compare/isBeforeDateTime.d.ts +17 -0
- package/dist/plain/compare/isBeforeDateTime.js +29 -0
- package/dist/plain/compare/isBeforeTime.d.ts +17 -0
- package/dist/plain/compare/isBeforeTime.js +29 -0
- package/dist/plain/compare/isBetweenDate.d.ts +26 -0
- package/dist/plain/compare/isBetweenDate.js +49 -0
- package/dist/plain/compare/isBetweenDateTime.d.ts +26 -0
- package/dist/plain/compare/isBetweenDateTime.js +51 -0
- package/dist/plain/compare/isBetweenTime.d.ts +28 -0
- package/dist/plain/compare/isBetweenTime.js +51 -0
- package/dist/plain/compare/isBusinessDay.d.ts +21 -0
- package/dist/plain/compare/isBusinessDay.js +33 -0
- package/dist/plain/compare/isFuture.d.ts +21 -0
- package/dist/plain/compare/isFuture.js +33 -0
- package/dist/plain/compare/isPast.d.ts +21 -0
- package/dist/plain/compare/isPast.js +33 -0
- package/dist/plain/compare/isRelativeDay.d.ts +32 -0
- package/dist/plain/compare/isRelativeDay.js +49 -0
- package/dist/plain/compare/isThisUnit.d.ts +35 -0
- package/dist/plain/compare/isThisUnit.js +52 -0
- package/dist/plain/compare/isWeekend.d.ts +21 -0
- package/dist/plain/compare/isWeekend.js +37 -0
- package/dist/plain/convert/convertDateToCalendar.d.ts +44 -0
- package/dist/plain/convert/convertDateToCalendar.js +59 -0
- package/dist/plain/convert/index.d.ts +1 -0
- package/dist/plain/convert/index.js +1 -0
- package/dist/plain/format/formatCalendar.d.ts +43 -0
- package/dist/plain/format/formatCalendar.js +70 -0
- package/dist/plain/format/formatDate.d.ts +17 -0
- package/dist/plain/format/formatDate.js +31 -0
- package/dist/plain/format/formatDateRange.d.ts +19 -0
- package/dist/plain/format/formatDateRange.js +33 -0
- package/dist/plain/format/formatDateTime.d.ts +17 -0
- package/dist/plain/format/formatDateTime.js +31 -0
- package/dist/plain/format/formatDateTimeRange.d.ts +19 -0
- package/dist/plain/format/formatDateTimeRange.js +33 -0
- package/dist/plain/format/formatDateTimeToParts.d.ts +28 -0
- package/dist/plain/format/formatDateTimeToParts.js +48 -0
- package/dist/plain/format/formatDateToParts.d.ts +27 -0
- package/dist/plain/format/formatDateToParts.js +47 -0
- package/dist/plain/format/formatRelativeDate.d.ts +32 -0
- package/dist/plain/format/formatRelativeDate.js +57 -0
- package/dist/plain/format/formatRelativeDateTime.d.ts +32 -0
- package/dist/plain/format/formatRelativeDateTime.js +57 -0
- package/dist/plain/format/formatRelativeTime.d.ts +32 -0
- package/dist/plain/format/formatRelativeTime.js +49 -0
- package/dist/plain/format/formatSql.d.ts +20 -0
- package/dist/plain/format/formatSql.js +31 -0
- package/dist/plain/format/formatTime.d.ts +17 -0
- package/dist/plain/format/formatTime.js +31 -0
- package/dist/plain/format/index.d.ts +12 -0
- package/dist/plain/format/index.js +12 -0
- package/dist/plain/get/getDay.d.ts +13 -0
- package/dist/plain/get/getDay.js +27 -0
- package/dist/plain/get/getDayOfWeek.d.ts +13 -0
- package/dist/plain/get/getDayOfWeek.js +26 -0
- package/dist/plain/get/getHour.d.ts +13 -0
- package/dist/plain/get/getHour.js +27 -0
- package/dist/plain/get/getMicrosecond.d.ts +13 -0
- package/dist/plain/get/getMicrosecond.js +27 -0
- package/dist/plain/get/getMillisecond.d.ts +13 -0
- package/dist/plain/get/getMillisecond.js +27 -0
- package/dist/plain/get/getMinute.d.ts +13 -0
- package/dist/plain/get/getMinute.js +27 -0
- package/dist/plain/get/getMonth.d.ts +13 -0
- package/dist/plain/get/getMonth.js +27 -0
- package/dist/plain/get/getNanosecond.d.ts +13 -0
- package/dist/plain/get/getNanosecond.js +27 -0
- package/dist/plain/get/getNow.d.ts +11 -0
- package/dist/plain/get/getNow.js +24 -0
- package/dist/plain/get/getNowUnit.d.ts +27 -0
- package/dist/plain/get/getNowUnit.js +72 -0
- package/dist/plain/get/getSecond.d.ts +13 -0
- package/dist/plain/get/getSecond.js +27 -0
- package/dist/plain/get/getToday.d.ts +11 -0
- package/dist/plain/get/getToday.js +24 -0
- package/dist/plain/get/getWeekOfYear.d.ts +13 -0
- package/dist/plain/get/getWeekOfYear.js +32 -0
- package/dist/plain/get/getYear.d.ts +13 -0
- package/dist/plain/get/getYear.js +27 -0
- package/dist/plain/get/index.d.ts +14 -0
- package/dist/plain/get/index.js +14 -0
- package/dist/plain/index.d.ts +12 -0
- package/dist/plain/index.js +13 -0
- package/dist/plain/interval/index.d.ts +51 -0
- package/dist/plain/interval/index.js +51 -0
- package/dist/plain/interval/intervalAbutsDate.d.ts +26 -0
- package/dist/plain/interval/intervalAbutsDate.js +68 -0
- package/dist/plain/interval/intervalAbutsDateTime.d.ts +22 -0
- package/dist/plain/interval/intervalAbutsDateTime.js +63 -0
- package/dist/plain/interval/intervalAbutsTime.d.ts +22 -0
- package/dist/plain/interval/intervalAbutsTime.js +63 -0
- package/dist/plain/interval/intervalContainsDate.d.ts +26 -0
- package/dist/plain/interval/intervalContainsDate.js +63 -0
- package/dist/plain/interval/intervalContainsDateTime.d.ts +24 -0
- package/dist/plain/interval/intervalContainsDateTime.js +60 -0
- package/dist/plain/interval/intervalContainsTime.d.ts +24 -0
- package/dist/plain/interval/intervalContainsTime.js +60 -0
- package/dist/plain/interval/intervalCountDate.d.ts +31 -0
- package/dist/plain/interval/intervalCountDate.js +62 -0
- package/dist/plain/interval/intervalCountDateTime.d.ts +26 -0
- package/dist/plain/interval/intervalCountDateTime.js +73 -0
- package/dist/plain/interval/intervalCountTime.d.ts +26 -0
- package/dist/plain/interval/intervalCountTime.js +67 -0
- package/dist/plain/interval/intervalDifferenceDate.d.ts +30 -0
- package/dist/plain/interval/intervalDifferenceDate.js +87 -0
- package/dist/plain/interval/intervalDifferenceDateTime.d.ts +24 -0
- package/dist/plain/interval/intervalDifferenceDateTime.js +69 -0
- package/dist/plain/interval/intervalDifferenceTime.d.ts +25 -0
- package/dist/plain/interval/intervalDifferenceTime.js +70 -0
- package/dist/plain/interval/intervalDivideEquallyDate.d.ts +33 -0
- package/dist/plain/interval/intervalDivideEquallyDate.js +70 -0
- package/dist/plain/interval/intervalDivideEquallyDateTime.d.ts +27 -0
- package/dist/plain/interval/intervalDivideEquallyDateTime.js +62 -0
- package/dist/plain/interval/intervalDivideEquallyTime.d.ts +28 -0
- package/dist/plain/interval/intervalDivideEquallyTime.js +63 -0
- package/dist/plain/interval/intervalEngulfsDate.d.ts +24 -0
- package/dist/plain/interval/intervalEngulfsDate.js +57 -0
- package/dist/plain/interval/intervalEngulfsDateTime.d.ts +22 -0
- package/dist/plain/interval/intervalEngulfsDateTime.js +54 -0
- package/dist/plain/interval/intervalEngulfsTime.d.ts +22 -0
- package/dist/plain/interval/intervalEngulfsTime.js +54 -0
- package/dist/plain/interval/intervalFromDurationDate.d.ts +39 -0
- package/dist/plain/interval/intervalFromDurationDate.js +71 -0
- package/dist/plain/interval/intervalFromDurationDateTime.d.ts +33 -0
- package/dist/plain/interval/intervalFromDurationDateTime.js +58 -0
- package/dist/plain/interval/intervalFromDurationTime.d.ts +38 -0
- package/dist/plain/interval/intervalFromDurationTime.js +69 -0
- package/dist/plain/interval/intervalIntersectionDate.d.ts +28 -0
- package/dist/plain/interval/intervalIntersectionDate.js +70 -0
- package/dist/plain/interval/intervalIntersectionDateTime.d.ts +23 -0
- package/dist/plain/interval/intervalIntersectionDateTime.js +57 -0
- package/dist/plain/interval/intervalIntersectionTime.d.ts +24 -0
- package/dist/plain/interval/intervalIntersectionTime.js +58 -0
- package/dist/plain/interval/intervalLengthDate.d.ts +31 -0
- package/dist/plain/interval/intervalLengthDate.js +56 -0
- package/dist/plain/interval/intervalLengthDateTime.d.ts +24 -0
- package/dist/plain/interval/intervalLengthDateTime.js +50 -0
- package/dist/plain/interval/intervalLengthTime.d.ts +23 -0
- package/dist/plain/interval/intervalLengthTime.js +49 -0
- package/dist/plain/interval/intervalOverlappingDaysDate.d.ts +33 -0
- package/dist/plain/interval/intervalOverlappingDaysDate.js +78 -0
- package/dist/plain/interval/intervalOverlappingDaysDateTime.d.ts +28 -0
- package/dist/plain/interval/intervalOverlappingDaysDateTime.js +67 -0
- package/dist/plain/interval/intervalSplitAtDate.d.ts +34 -0
- package/dist/plain/interval/intervalSplitAtDate.js +73 -0
- package/dist/plain/interval/intervalSplitAtDateTime.d.ts +28 -0
- package/dist/plain/interval/intervalSplitAtDateTime.js +62 -0
- package/dist/plain/interval/intervalSplitAtTime.d.ts +30 -0
- package/dist/plain/interval/intervalSplitAtTime.js +64 -0
- package/dist/plain/interval/intervalUnionDate.d.ts +29 -0
- package/dist/plain/interval/intervalUnionDate.js +71 -0
- package/dist/plain/interval/intervalUnionDateTime.d.ts +24 -0
- package/dist/plain/interval/intervalUnionDateTime.js +58 -0
- package/dist/plain/interval/intervalUnionTime.d.ts +24 -0
- package/dist/plain/interval/intervalUnionTime.js +58 -0
- package/dist/plain/interval/intervalXorAllDate.d.ts +35 -0
- package/dist/plain/interval/intervalXorAllDate.js +89 -0
- package/dist/plain/interval/intervalXorAllDateTime.d.ts +29 -0
- package/dist/plain/interval/intervalXorAllDateTime.js +77 -0
- package/dist/plain/interval/intervalXorAllTime.d.ts +28 -0
- package/dist/plain/interval/intervalXorAllTime.js +76 -0
- package/dist/plain/interval/intervalXorDate.d.ts +30 -0
- package/dist/plain/interval/intervalXorDate.js +106 -0
- package/dist/plain/interval/intervalXorDateTime.d.ts +25 -0
- package/dist/plain/interval/intervalXorDateTime.js +90 -0
- package/dist/plain/interval/intervalXorTime.d.ts +26 -0
- package/dist/plain/interval/intervalXorTime.js +91 -0
- package/dist/plain/interval/intervalsOverlapDate.d.ts +23 -0
- package/dist/plain/interval/intervalsOverlapDate.js +56 -0
- package/dist/plain/interval/intervalsOverlapDateTime.d.ts +20 -0
- package/dist/plain/interval/intervalsOverlapDateTime.js +52 -0
- package/dist/plain/interval/intervalsOverlapTime.d.ts +21 -0
- package/dist/plain/interval/intervalsOverlapTime.js +53 -0
- package/dist/plain/interval/mergeIntervalsDate.d.ts +31 -0
- package/dist/plain/interval/mergeIntervalsDate.js +67 -0
- package/dist/plain/interval/mergeIntervalsDateTime.d.ts +26 -0
- package/dist/plain/interval/mergeIntervalsDateTime.js +58 -0
- package/dist/plain/interval/mergeIntervalsTime.d.ts +26 -0
- package/dist/plain/interval/mergeIntervalsTime.js +57 -0
- package/dist/plain/interval/splitIntervalByUnitDate.d.ts +32 -0
- package/dist/plain/interval/splitIntervalByUnitDate.js +80 -0
- package/dist/plain/interval/splitIntervalByUnitDateTime.d.ts +24 -0
- package/dist/plain/interval/splitIntervalByUnitDateTime.js +72 -0
- package/dist/plain/interval/splitIntervalByUnitTime.d.ts +25 -0
- package/dist/plain/interval/splitIntervalByUnitTime.js +73 -0
- package/dist/plain/interval/validate/index.d.ts +3 -0
- package/dist/plain/interval/validate/index.js +3 -0
- package/dist/plain/interval/validate/isValidDateInterval.d.ts +21 -0
- package/dist/plain/interval/validate/isValidDateInterval.js +37 -0
- package/dist/plain/interval/validate/isValidDateTimeInterval.d.ts +18 -0
- package/dist/plain/interval/validate/isValidDateTimeInterval.js +33 -0
- package/dist/plain/interval/validate/isValidTimeInterval.d.ts +18 -0
- package/dist/plain/interval/validate/isValidTimeInterval.js +48 -0
- package/dist/plain/locale/getLocaleEraNames.d.ts +23 -0
- package/dist/plain/locale/getLocaleEraNames.js +66 -0
- package/dist/plain/locale/getLocaleMeridiems.d.ts +19 -0
- package/dist/plain/locale/getLocaleMeridiems.js +44 -0
- package/dist/plain/locale/getLocaleMonthNames.d.ts +28 -0
- package/dist/plain/locale/getLocaleMonthNames.js +45 -0
- package/dist/plain/locale/getLocaleWeekdayNames.d.ts +25 -0
- package/dist/plain/locale/getLocaleWeekdayNames.js +48 -0
- package/dist/plain/locale/index.d.ts +4 -0
- package/dist/plain/locale/index.js +4 -0
- package/dist/plain/map/index.d.ts +2 -0
- package/dist/plain/map/index.js +2 -0
- package/dist/plain/map/mapDatesInRange.d.ts +19 -0
- package/dist/plain/map/mapDatesInRange.js +46 -0
- package/dist/plain/map/mapDaysInMonth.d.ts +15 -0
- package/dist/plain/map/mapDaysInMonth.js +31 -0
- package/dist/plain/parse/index.d.ts +29 -0
- package/dist/plain/parse/index.js +29 -0
- package/dist/plain/parse/parseDateTimeWithPattern.d.ts +85 -0
- package/dist/plain/parse/parseDateTimeWithPattern.js +116 -0
- package/dist/plain/parse/parseDateWithPattern.d.ts +68 -0
- package/dist/plain/parse/parseDateWithPattern.js +91 -0
- package/dist/plain/parse/parseDayFromDate.d.ts +13 -0
- package/dist/plain/parse/parseDayFromDate.js +25 -0
- package/dist/plain/parse/parseDayFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseDayFromDateTime.js +26 -0
- package/dist/plain/parse/parseDayOfWeekFromDate.d.ts +15 -0
- package/dist/plain/parse/parseDayOfWeekFromDate.js +28 -0
- package/dist/plain/parse/parseDayOfWeekFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseDayOfWeekFromDateTime.js +27 -0
- package/dist/plain/parse/parseHourFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseHourFromDateTime.js +26 -0
- package/dist/plain/parse/parseHourFromTime.d.ts +13 -0
- package/dist/plain/parse/parseHourFromTime.js +25 -0
- package/dist/plain/parse/parseMicrosecondFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseMicrosecondFromDateTime.js +26 -0
- package/dist/plain/parse/parseMicrosecondFromTime.d.ts +11 -0
- package/dist/plain/parse/parseMicrosecondFromTime.js +23 -0
- package/dist/plain/parse/parseMillisecondFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseMillisecondFromDateTime.js +26 -0
- package/dist/plain/parse/parseMillisecondFromTime.d.ts +14 -0
- package/dist/plain/parse/parseMillisecondFromTime.js +26 -0
- package/dist/plain/parse/parseMinuteFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseMinuteFromDateTime.js +26 -0
- package/dist/plain/parse/parseMinuteFromTime.d.ts +14 -0
- package/dist/plain/parse/parseMinuteFromTime.js +26 -0
- package/dist/plain/parse/parseMonthFromDate.d.ts +13 -0
- package/dist/plain/parse/parseMonthFromDate.js +25 -0
- package/dist/plain/parse/parseMonthFromDateTime.d.ts +13 -0
- package/dist/plain/parse/parseMonthFromDateTime.js +25 -0
- package/dist/plain/parse/parseNanosecondFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseNanosecondFromDateTime.js +26 -0
- package/dist/plain/parse/parseNanosecondFromTime.d.ts +14 -0
- package/dist/plain/parse/parseNanosecondFromTime.js +26 -0
- package/dist/plain/parse/parseSecondFromDateTime.d.ts +14 -0
- package/dist/plain/parse/parseSecondFromDateTime.js +26 -0
- package/dist/plain/parse/parseSecondFromTime.d.ts +14 -0
- package/dist/plain/parse/parseSecondFromTime.js +26 -0
- package/dist/plain/parse/parseSql.d.ts +23 -0
- package/dist/plain/parse/parseSql.js +36 -0
- package/dist/plain/parse/parseTimeWithPattern.d.ts +57 -0
- package/dist/plain/parse/parseTimeWithPattern.js +85 -0
- package/dist/plain/parse/parseUnitFromDate.d.ts +23 -0
- package/dist/plain/parse/parseUnitFromDate.js +49 -0
- package/dist/plain/parse/parseUnitFromDateTime.d.ts +22 -0
- package/dist/plain/parse/parseUnitFromDateTime.js +56 -0
- package/dist/plain/parse/parseUnitFromTime.d.ts +18 -0
- package/dist/plain/parse/parseUnitFromTime.js +42 -0
- package/dist/plain/parse/parseWeekFromDate.d.ts +19 -0
- package/dist/plain/parse/parseWeekFromDate.js +30 -0
- package/dist/plain/parse/parseWeekFromDateTime.d.ts +18 -0
- package/dist/plain/parse/parseWeekFromDateTime.js +29 -0
- package/dist/plain/parse/parseYearFromDate.d.ts +13 -0
- package/dist/plain/parse/parseYearFromDate.js +25 -0
- package/dist/plain/parse/parseYearFromDateTime.d.ts +13 -0
- package/dist/plain/parse/parseYearFromDateTime.js +25 -0
- package/dist/plain/validate/index.d.ts +19 -0
- package/dist/plain/validate/index.js +19 -0
- package/dist/plain/validate/isLeapSecond.d.ts +16 -0
- package/dist/plain/validate/isLeapSecond.js +19 -0
- package/dist/plain/validate/isLeapYear.d.ts +14 -0
- package/dist/plain/validate/isLeapYear.js +23 -0
- package/dist/plain/validate/isValidCalendarDate.d.ts +17 -0
- package/dist/plain/validate/isValidCalendarDate.js +29 -0
- package/dist/plain/validate/isValidDate.d.ts +16 -0
- package/dist/plain/validate/isValidDate.js +33 -0
- package/dist/plain/validate/isValidDateCycleField.d.ts +21 -0
- package/dist/plain/validate/isValidDateCycleField.js +25 -0
- package/dist/plain/validate/isValidDateDurationUnit.d.ts +16 -0
- package/dist/plain/validate/isValidDateDurationUnit.js +17 -0
- package/dist/plain/validate/isValidDateRange.d.ts +26 -0
- package/dist/plain/validate/isValidDateRange.js +47 -0
- package/dist/plain/validate/isValidDateTime.d.ts +16 -0
- package/dist/plain/validate/isValidDateTime.js +33 -0
- package/dist/plain/validate/isValidDateTimeCycleField.d.ts +16 -0
- package/dist/plain/validate/isValidDateTimeCycleField.js +19 -0
- package/dist/plain/validate/isValidDateTimeDurationUnit.d.ts +16 -0
- package/dist/plain/validate/isValidDateTimeDurationUnit.js +26 -0
- package/dist/plain/validate/isValidDateTimeRange.d.ts +24 -0
- package/dist/plain/validate/isValidDateTimeRange.js +39 -0
- package/dist/plain/validate/isValidDateTimeUnit.d.ts +19 -0
- package/dist/plain/validate/isValidDateTimeUnit.js +32 -0
- package/dist/plain/validate/isValidDateUnit.d.ts +21 -0
- package/dist/plain/validate/isValidDateUnit.js +25 -0
- package/dist/plain/validate/isValidIsoDateLike.d.ts +17 -0
- package/dist/plain/validate/isValidIsoDateLike.js +43 -0
- package/dist/plain/validate/isValidTime.d.ts +16 -0
- package/dist/plain/validate/isValidTime.js +33 -0
- package/dist/plain/validate/isValidTimeCycleField.d.ts +18 -0
- package/dist/plain/validate/isValidTimeCycleField.js +27 -0
- package/dist/plain/validate/isValidTimeDurationUnit.d.ts +16 -0
- package/dist/plain/validate/isValidTimeDurationUnit.js +22 -0
- package/dist/plain/validate/isValidTimeRange.d.ts +24 -0
- package/dist/plain/validate/isValidTimeRange.js +51 -0
- package/dist/plain/validate/isValidTimeUnit.d.ts +19 -0
- package/dist/plain/validate/isValidTimeUnit.js +28 -0
- package/dist/regex/calendar-date.d.ts +1 -0
- package/dist/regex/calendar-date.js +11 -0
- package/dist/regex/calendar-zoned-date-time.d.ts +1 -0
- package/dist/regex/calendar-zoned-date-time.js +41 -0
- package/dist/regex/date-time.d.ts +1 -0
- package/dist/regex/date-time.js +2 -0
- package/dist/regex/date.d.ts +4 -0
- package/dist/regex/date.js +5 -0
- package/dist/regex/http-date.d.ts +1 -0
- package/dist/regex/http-date.js +7 -0
- package/dist/regex/index.d.ts +13 -0
- package/dist/regex/index.js +13 -0
- package/dist/regex/leap-second.d.ts +1 -0
- package/dist/regex/leap-second.js +2 -0
- package/dist/regex/rfc-2822.d.ts +1 -0
- package/dist/regex/rfc-2822.js +9 -0
- package/dist/regex/rfc-3339.d.ts +1 -0
- package/dist/regex/rfc-3339.js +7 -0
- package/dist/regex/sql-date-time.d.ts +1 -0
- package/dist/regex/sql-date-time.js +7 -0
- package/dist/regex/time-zone-like.d.ts +1 -0
- package/dist/regex/time-zone-like.js +1 -0
- package/dist/regex/time.d.ts +6 -0
- package/dist/regex/time.js +9 -0
- package/dist/regex/unix.d.ts +2 -0
- package/dist/regex/unix.js +2 -0
- package/dist/regex/utc-date-time.d.ts +1 -0
- package/dist/regex/utc-date-time.js +2 -0
- package/dist/types/calendar-system.d.ts +1 -0
- package/dist/types/calendar-system.js +0 -0
- package/dist/types/date-cycle-field.d.ts +1 -0
- package/dist/types/date-cycle-field.js +0 -0
- package/dist/types/date-duration-unit.d.ts +2 -0
- package/dist/types/date-duration-unit.js +0 -0
- package/dist/types/date-time-cycle-field.d.ts +3 -0
- package/dist/types/date-time-cycle-field.js +0 -0
- package/dist/types/date-time-duration-units.d.ts +2 -0
- package/dist/types/date-time-duration-units.js +0 -0
- package/dist/types/date-time-unit.d.ts +2 -0
- package/dist/types/date-time-unit.js +0 -0
- package/dist/types/date-unit.d.ts +2 -0
- package/dist/types/date-unit.js +0 -0
- package/dist/types/disambiguation.d.ts +2 -0
- package/dist/types/disambiguation.js +0 -0
- package/dist/types/duration-relative-to.d.ts +2 -0
- package/dist/types/duration-relative-to.js +0 -0
- package/dist/types/duration-string-options.d.ts +6 -0
- package/dist/types/duration-string-options.js +0 -0
- package/dist/types/fractional-digit.d.ts +1 -0
- package/dist/types/fractional-digit.js +0 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +18 -0
- package/dist/types/offset.d.ts +2 -0
- package/dist/types/offset.js +0 -0
- package/dist/types/overflow.d.ts +2 -0
- package/dist/types/overflow.js +0 -0
- package/dist/types/relative-rounding-method.d.ts +1 -0
- package/dist/types/relative-rounding-method.js +0 -0
- package/dist/types/rounding-options.d.ts +6 -0
- package/dist/types/rounding-options.js +0 -0
- package/dist/types/time-cycle-field.d.ts +1 -0
- package/dist/types/time-cycle-field.js +0 -0
- package/dist/types/time-duration-unit.d.ts +2 -0
- package/dist/types/time-duration-unit.js +0 -0
- package/dist/types/time-unit.d.ts +2 -0
- package/dist/types/time-unit.js +0 -0
- package/dist/unix/calculate/addUnix.d.ts +25 -0
- package/dist/unix/calculate/addUnix.js +51 -0
- package/dist/unix/calculate/diffUnix.d.ts +30 -0
- package/dist/unix/calculate/diffUnix.js +66 -0
- package/dist/unix/calculate/diffUnixAsDuration.d.ts +35 -0
- package/dist/unix/calculate/diffUnixAsDuration.js +56 -0
- package/dist/unix/calculate/endOfQuarterForUnix.d.ts +23 -0
- package/dist/unix/calculate/endOfQuarterForUnix.js +56 -0
- package/dist/unix/calculate/endOfUnix.d.ts +30 -0
- package/dist/unix/calculate/endOfUnix.js +26 -0
- package/dist/unix/calculate/index.d.ts +14 -0
- package/dist/unix/calculate/index.js +14 -0
- package/dist/unix/calculate/isBetweenUnix.d.ts +23 -0
- package/dist/unix/calculate/isBetweenUnix.js +54 -0
- package/dist/unix/calculate/maxUnix.d.ts +13 -0
- package/dist/unix/calculate/maxUnix.js +21 -0
- package/dist/unix/calculate/minUnix.d.ts +13 -0
- package/dist/unix/calculate/minUnix.js +21 -0
- package/dist/unix/calculate/roundUnix.d.ts +27 -0
- package/dist/unix/calculate/roundUnix.js +62 -0
- package/dist/unix/calculate/setUnix.d.ts +35 -0
- package/dist/unix/calculate/setUnix.js +60 -0
- package/dist/unix/calculate/sortUnix.d.ts +16 -0
- package/dist/unix/calculate/sortUnix.js +28 -0
- package/dist/unix/calculate/startOfQuarterForUnix.d.ts +23 -0
- package/dist/unix/calculate/startOfQuarterForUnix.js +46 -0
- package/dist/unix/calculate/startOfUnix.d.ts +30 -0
- package/dist/unix/calculate/startOfUnix.js +26 -0
- package/dist/unix/calculate/startOrEndOfUnix.d.ts +9 -0
- package/dist/unix/calculate/startOrEndOfUnix.js +122 -0
- package/dist/unix/calculate/subtractUnix.d.ts +25 -0
- package/dist/unix/calculate/subtractUnix.js +51 -0
- package/dist/unix/compare/areUnixEqual.d.ts +21 -0
- package/dist/unix/compare/areUnixEqual.js +33 -0
- package/dist/unix/compare/areUnixEqualBy.d.ts +31 -0
- package/dist/unix/compare/areUnixEqualBy.js +39 -0
- package/dist/unix/compare/index.d.ts +4 -0
- package/dist/unix/compare/index.js +4 -0
- package/dist/unix/compare/isAfterUnix.d.ts +19 -0
- package/dist/unix/compare/isAfterUnix.js +31 -0
- package/dist/unix/compare/isBeforeUnix.d.ts +21 -0
- package/dist/unix/compare/isBeforeUnix.js +33 -0
- package/dist/unix/convert/convertUnixToPlainDate.d.ts +19 -0
- package/dist/unix/convert/convertUnixToPlainDate.js +38 -0
- package/dist/unix/convert/convertUnixToPlainDateTime.d.ts +19 -0
- package/dist/unix/convert/convertUnixToPlainDateTime.js +38 -0
- package/dist/unix/convert/convertUnixToPlainTime.d.ts +19 -0
- package/dist/unix/convert/convertUnixToPlainTime.js +38 -0
- package/dist/unix/convert/convertUnixToUtc.d.ts +17 -0
- package/dist/unix/convert/convertUnixToUtc.js +31 -0
- package/dist/unix/convert/convertUnixToZoned.d.ts +18 -0
- package/dist/unix/convert/convertUnixToZoned.js +35 -0
- package/dist/unix/convert/index.d.ts +5 -0
- package/dist/unix/convert/index.js +5 -0
- package/dist/unix/format/formatCalendarUnix.d.ts +29 -0
- package/dist/unix/format/formatCalendarUnix.js +107 -0
- package/dist/unix/format/formatRelativeUnix.d.ts +34 -0
- package/dist/unix/format/formatRelativeUnix.js +118 -0
- package/dist/unix/format/formatUnix.d.ts +6 -0
- package/dist/unix/format/formatUnix.js +41 -0
- package/dist/unix/format/index.d.ts +3 -0
- package/dist/unix/format/index.js +3 -0
- package/dist/unix/get/getUnixDay.d.ts +13 -0
- package/dist/unix/get/getUnixDay.js +24 -0
- package/dist/unix/get/getUnixHour.d.ts +13 -0
- package/dist/unix/get/getUnixHour.js +24 -0
- package/dist/unix/get/getUnixMicrosecond.d.ts +13 -0
- package/dist/unix/get/getUnixMicrosecond.js +23 -0
- package/dist/unix/get/getUnixMillisecond.d.ts +13 -0
- package/dist/unix/get/getUnixMillisecond.js +24 -0
- package/dist/unix/get/getUnixMinute.d.ts +13 -0
- package/dist/unix/get/getUnixMinute.js +24 -0
- package/dist/unix/get/getUnixMonth.d.ts +13 -0
- package/dist/unix/get/getUnixMonth.js +24 -0
- package/dist/unix/get/getUnixNanosecond.d.ts +13 -0
- package/dist/unix/get/getUnixNanosecond.js +23 -0
- package/dist/unix/get/getUnixNow.d.ts +15 -0
- package/dist/unix/get/getUnixNow.js +28 -0
- package/dist/unix/get/getUnixNowUnit.d.ts +18 -0
- package/dist/unix/get/getUnixNowUnit.js +61 -0
- package/dist/unix/get/getUnixSecond.d.ts +13 -0
- package/dist/unix/get/getUnixSecond.js +24 -0
- package/dist/unix/get/getUnixYear.d.ts +13 -0
- package/dist/unix/get/getUnixYear.js +24 -0
- package/dist/unix/get/index.d.ts +11 -0
- package/dist/unix/get/index.js +11 -0
- package/dist/unix/index.d.ts +8 -0
- package/dist/unix/index.js +8 -0
- package/dist/unix/interval/index.d.ts +18 -0
- package/dist/unix/interval/index.js +18 -0
- package/dist/unix/interval/intervalAbutsUnix.d.ts +22 -0
- package/dist/unix/interval/intervalAbutsUnix.js +54 -0
- package/dist/unix/interval/intervalContainsUnix.d.ts +25 -0
- package/dist/unix/interval/intervalContainsUnix.js +60 -0
- package/dist/unix/interval/intervalCountUnix.d.ts +28 -0
- package/dist/unix/interval/intervalCountUnix.js +44 -0
- package/dist/unix/interval/intervalDifferenceUnix.d.ts +24 -0
- package/dist/unix/interval/intervalDifferenceUnix.js +57 -0
- package/dist/unix/interval/intervalDivideEquallyUnix.d.ts +27 -0
- package/dist/unix/interval/intervalDivideEquallyUnix.js +54 -0
- package/dist/unix/interval/intervalEngulfsUnix.d.ts +22 -0
- package/dist/unix/interval/intervalEngulfsUnix.js +46 -0
- package/dist/unix/interval/intervalFromDurationUnix.d.ts +37 -0
- package/dist/unix/interval/intervalFromDurationUnix.js +73 -0
- package/dist/unix/interval/intervalIntersectionUnix.d.ts +24 -0
- package/dist/unix/interval/intervalIntersectionUnix.js +57 -0
- package/dist/unix/interval/intervalLengthUnix.d.ts +24 -0
- package/dist/unix/interval/intervalLengthUnix.js +39 -0
- package/dist/unix/interval/intervalOverlappingDaysUnix.d.ts +34 -0
- package/dist/unix/interval/intervalOverlappingDaysUnix.js +89 -0
- package/dist/unix/interval/intervalSplitAtUnix.d.ts +26 -0
- package/dist/unix/interval/intervalSplitAtUnix.js +55 -0
- package/dist/unix/interval/intervalUnionUnix.d.ts +25 -0
- package/dist/unix/interval/intervalUnionUnix.js +58 -0
- package/dist/unix/interval/intervalXorAllUnix.d.ts +28 -0
- package/dist/unix/interval/intervalXorAllUnix.js +77 -0
- package/dist/unix/interval/intervalXorUnix.d.ts +25 -0
- package/dist/unix/interval/intervalXorUnix.js +70 -0
- package/dist/unix/interval/intervalsOverlapUnix.d.ts +21 -0
- package/dist/unix/interval/intervalsOverlapUnix.js +51 -0
- package/dist/unix/interval/mergeIntervalsUnix.d.ts +25 -0
- package/dist/unix/interval/mergeIntervalsUnix.js +55 -0
- package/dist/unix/interval/resolveUnixIntervalPair.d.ts +7 -0
- package/dist/unix/interval/resolveUnixIntervalPair.js +36 -0
- package/dist/unix/interval/splitIntervalByUnitUnix.d.ts +27 -0
- package/dist/unix/interval/splitIntervalByUnitUnix.js +85 -0
- package/dist/unix/interval/validate/index.d.ts +1 -0
- package/dist/unix/interval/validate/index.js +1 -0
- package/dist/unix/interval/validate/isValidUnixInterval.d.ts +18 -0
- package/dist/unix/interval/validate/isValidUnixInterval.js +31 -0
- package/dist/unix/parse/index.d.ts +12 -0
- package/dist/unix/parse/index.js +12 -0
- package/dist/unix/parse/parseDateFromUnix.d.ts +20 -0
- package/dist/unix/parse/parseDateFromUnix.js +45 -0
- package/dist/unix/parse/parseDayFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseDayFromUnix.js +17 -0
- package/dist/unix/parse/parseDayOfWeekFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseDayOfWeekFromUnix.js +44 -0
- package/dist/unix/parse/parseHourFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseHourFromUnix.js +17 -0
- package/dist/unix/parse/parseMicrosecondFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseMicrosecondFromUnix.js +17 -0
- package/dist/unix/parse/parseMillisecondFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseMillisecondFromUnix.js +17 -0
- package/dist/unix/parse/parseMinuteFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseMinuteFromUnix.js +17 -0
- package/dist/unix/parse/parseMonthFromUnix.d.ts +19 -0
- package/dist/unix/parse/parseMonthFromUnix.js +18 -0
- package/dist/unix/parse/parseNanosecondFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseNanosecondFromUnix.js +17 -0
- package/dist/unix/parse/parseSecondFromUnix.d.ts +18 -0
- package/dist/unix/parse/parseSecondFromUnix.js +17 -0
- package/dist/unix/parse/parseTimeFromUnix.d.ts +20 -0
- package/dist/unix/parse/parseTimeFromUnix.js +45 -0
- package/dist/unix/parse/parseUnitFromUnix.d.ts +25 -0
- package/dist/unix/parse/parseUnitFromUnix.js +77 -0
- package/dist/unix/parse/parseWeekFromUnix.d.ts +20 -0
- package/dist/unix/parse/parseWeekFromUnix.js +47 -0
- package/dist/unix/parse/parseYearFromUnix.d.ts +19 -0
- package/dist/unix/parse/parseYearFromUnix.js +18 -0
- package/dist/unix/validate/index.d.ts +4 -0
- package/dist/unix/validate/index.js +4 -0
- package/dist/unix/validate/isValidUnixMilliseconds.d.ts +14 -0
- package/dist/unix/validate/isValidUnixMilliseconds.js +19 -0
- package/dist/unix/validate/isValidUnixRange.d.ts +24 -0
- package/dist/unix/validate/isValidUnixRange.js +34 -0
- package/dist/unix/validate/isValidUnixSeconds.d.ts +14 -0
- package/dist/unix/validate/isValidUnixSeconds.js +19 -0
- package/dist/unix/validate/isValidUnixUnit.d.ts +18 -0
- package/dist/unix/validate/isValidUnixUnit.js +22 -0
- package/dist/utc/calculate/addUtc.d.ts +23 -0
- package/dist/utc/calculate/addUtc.js +42 -0
- package/dist/utc/calculate/diffUtc.d.ts +27 -0
- package/dist/utc/calculate/diffUtc.js +61 -0
- package/dist/utc/calculate/diffUtcAsDuration.d.ts +31 -0
- package/dist/utc/calculate/diffUtcAsDuration.js +50 -0
- package/dist/utc/calculate/endOfQuarterForUtc.d.ts +14 -0
- package/dist/utc/calculate/endOfQuarterForUtc.js +49 -0
- package/dist/utc/calculate/endOfUtc.d.ts +22 -0
- package/dist/utc/calculate/endOfUtc.js +21 -0
- package/dist/utc/calculate/index.d.ts +14 -0
- package/dist/utc/calculate/index.js +14 -0
- package/dist/utc/calculate/isBetweenUtc.d.ts +21 -0
- package/dist/utc/calculate/isBetweenUtc.js +52 -0
- package/dist/utc/calculate/maxUtc.d.ts +15 -0
- package/dist/utc/calculate/maxUtc.js +35 -0
- package/dist/utc/calculate/minUtc.d.ts +15 -0
- package/dist/utc/calculate/minUtc.js +35 -0
- package/dist/utc/calculate/roundUtc.d.ts +26 -0
- package/dist/utc/calculate/roundUtc.js +56 -0
- package/dist/utc/calculate/setUtc.d.ts +38 -0
- package/dist/utc/calculate/setUtc.js +54 -0
- package/dist/utc/calculate/sortUtc.d.ts +17 -0
- package/dist/utc/calculate/sortUtc.js +36 -0
- package/dist/utc/calculate/startOfQuarterForUtc.d.ts +13 -0
- package/dist/utc/calculate/startOfQuarterForUtc.js +32 -0
- package/dist/utc/calculate/startOfUtc.d.ts +22 -0
- package/dist/utc/calculate/startOfUtc.js +21 -0
- package/dist/utc/calculate/startOrEndOfUtc.d.ts +6 -0
- package/dist/utc/calculate/startOrEndOfUtc.js +143 -0
- package/dist/utc/calculate/subtractUtc.d.ts +23 -0
- package/dist/utc/calculate/subtractUtc.js +42 -0
- package/dist/utc/chop/chopUtc.d.ts +14 -0
- package/dist/utc/chop/chopUtc.js +21 -0
- package/dist/utc/chop/index.d.ts +1 -0
- package/dist/utc/chop/index.js +1 -0
- package/dist/utc/compare/areUtcEqual.d.ts +15 -0
- package/dist/utc/compare/areUtcEqual.js +29 -0
- package/dist/utc/compare/areUtcEqualBy.d.ts +30 -0
- package/dist/utc/compare/areUtcEqualBy.js +45 -0
- package/dist/utc/compare/index.d.ts +4 -0
- package/dist/utc/compare/index.js +4 -0
- package/dist/utc/compare/isAfterUtc.d.ts +15 -0
- package/dist/utc/compare/isAfterUtc.js +28 -0
- package/dist/utc/compare/isBeforeUtc.d.ts +15 -0
- package/dist/utc/compare/isBeforeUtc.js +29 -0
- package/dist/utc/convert/convertUtcToPlainDate.d.ts +18 -0
- package/dist/utc/convert/convertUtcToPlainDate.js +35 -0
- package/dist/utc/convert/convertUtcToPlainDateTime.d.ts +18 -0
- package/dist/utc/convert/convertUtcToPlainDateTime.js +41 -0
- package/dist/utc/convert/convertUtcToPlainTime.d.ts +18 -0
- package/dist/utc/convert/convertUtcToPlainTime.js +35 -0
- package/dist/utc/convert/convertUtcToUnix.d.ts +17 -0
- package/dist/utc/convert/convertUtcToUnix.js +33 -0
- package/dist/utc/convert/convertUtcToZoned.d.ts +15 -0
- package/dist/utc/convert/convertUtcToZoned.js +28 -0
- package/dist/utc/convert/index.d.ts +5 -0
- package/dist/utc/convert/index.js +5 -0
- package/dist/utc/format/formatCalendarUtc.d.ts +28 -0
- package/dist/utc/format/formatCalendarUtc.js +68 -0
- package/dist/utc/format/formatHttp.d.ts +22 -0
- package/dist/utc/format/formatHttp.js +42 -0
- package/dist/utc/format/formatRelativeUtc.d.ts +33 -0
- package/dist/utc/format/formatRelativeUtc.js +76 -0
- package/dist/utc/format/formatUtc.d.ts +5 -0
- package/dist/utc/format/formatUtc.js +23 -0
- package/dist/utc/format/index.d.ts +4 -0
- package/dist/utc/format/index.js +4 -0
- package/dist/utc/get/getUtcDay.d.ts +13 -0
- package/dist/utc/get/getUtcDay.js +24 -0
- package/dist/utc/get/getUtcHour.d.ts +13 -0
- package/dist/utc/get/getUtcHour.js +24 -0
- package/dist/utc/get/getUtcMicrosecond.d.ts +13 -0
- package/dist/utc/get/getUtcMicrosecond.js +23 -0
- package/dist/utc/get/getUtcMillisecond.d.ts +13 -0
- package/dist/utc/get/getUtcMillisecond.js +24 -0
- package/dist/utc/get/getUtcMinute.d.ts +13 -0
- package/dist/utc/get/getUtcMinute.js +24 -0
- package/dist/utc/get/getUtcMonth.d.ts +13 -0
- package/dist/utc/get/getUtcMonth.js +24 -0
- package/dist/utc/get/getUtcNanosecond.d.ts +13 -0
- package/dist/utc/get/getUtcNanosecond.js +23 -0
- package/dist/utc/get/getUtcNow.d.ts +12 -0
- package/dist/utc/get/getUtcNow.js +20 -0
- package/dist/utc/get/getUtcNowUnit.d.ts +18 -0
- package/dist/utc/get/getUtcNowUnit.js +61 -0
- package/dist/utc/get/getUtcSecond.d.ts +13 -0
- package/dist/utc/get/getUtcSecond.js +24 -0
- package/dist/utc/get/getUtcYear.d.ts +13 -0
- package/dist/utc/get/getUtcYear.js +24 -0
- package/dist/utc/get/index.d.ts +11 -0
- package/dist/utc/get/index.js +11 -0
- package/dist/utc/index.d.ts +9 -0
- package/dist/utc/index.js +9 -0
- package/dist/utc/interval/index.d.ts +18 -0
- package/dist/utc/interval/index.js +18 -0
- package/dist/utc/interval/intervalAbutsUtc.d.ts +22 -0
- package/dist/utc/interval/intervalAbutsUtc.js +70 -0
- package/dist/utc/interval/intervalContainsUtc.d.ts +23 -0
- package/dist/utc/interval/intervalContainsUtc.js +66 -0
- package/dist/utc/interval/intervalCountUtc.d.ts +28 -0
- package/dist/utc/interval/intervalCountUtc.js +68 -0
- package/dist/utc/interval/intervalDifferenceUtc.d.ts +24 -0
- package/dist/utc/interval/intervalDifferenceUtc.js +76 -0
- package/dist/utc/interval/intervalDivideEquallyUtc.d.ts +26 -0
- package/dist/utc/interval/intervalDivideEquallyUtc.js +65 -0
- package/dist/utc/interval/intervalEngulfsUtc.d.ts +22 -0
- package/dist/utc/interval/intervalEngulfsUtc.js +61 -0
- package/dist/utc/interval/intervalFromDurationUtc.d.ts +35 -0
- package/dist/utc/interval/intervalFromDurationUtc.js +64 -0
- package/dist/utc/interval/intervalIntersectionUtc.d.ts +23 -0
- package/dist/utc/interval/intervalIntersectionUtc.js +64 -0
- package/dist/utc/interval/intervalLengthUtc.d.ts +22 -0
- package/dist/utc/interval/intervalLengthUtc.js +52 -0
- package/dist/utc/interval/intervalOverlappingDaysUtc.d.ts +29 -0
- package/dist/utc/interval/intervalOverlappingDaysUtc.js +75 -0
- package/dist/utc/interval/intervalSplitAtUtc.d.ts +27 -0
- package/dist/utc/interval/intervalSplitAtUtc.js +64 -0
- package/dist/utc/interval/intervalUnionUtc.d.ts +24 -0
- package/dist/utc/interval/intervalUnionUtc.js +65 -0
- package/dist/utc/interval/intervalXorAllUtc.d.ts +28 -0
- package/dist/utc/interval/intervalXorAllUtc.js +81 -0
- package/dist/utc/interval/intervalXorUtc.d.ts +25 -0
- package/dist/utc/interval/intervalXorUtc.js +97 -0
- package/dist/utc/interval/intervalsOverlapUtc.d.ts +20 -0
- package/dist/utc/interval/intervalsOverlapUtc.js +59 -0
- package/dist/utc/interval/mergeIntervalsUtc.d.ts +25 -0
- package/dist/utc/interval/mergeIntervalsUtc.js +61 -0
- package/dist/utc/interval/splitIntervalByUnitUtc.d.ts +25 -0
- package/dist/utc/interval/splitIntervalByUnitUtc.js +78 -0
- package/dist/utc/interval/validate/index.d.ts +1 -0
- package/dist/utc/interval/validate/index.js +1 -0
- package/dist/utc/interval/validate/isValidUtcInterval.d.ts +19 -0
- package/dist/utc/interval/validate/isValidUtcInterval.js +40 -0
- package/dist/utc/parse/index.d.ts +15 -0
- package/dist/utc/parse/index.js +15 -0
- package/dist/utc/parse/parseDateFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseDateFromUtc.js +27 -0
- package/dist/utc/parse/parseDayFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseDayFromUtc.js +26 -0
- package/dist/utc/parse/parseDayOfWeekFromUtc.d.ts +14 -0
- package/dist/utc/parse/parseDayOfWeekFromUtc.js +27 -0
- package/dist/utc/parse/parseHourFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseHourFromUtc.js +26 -0
- package/dist/utc/parse/parseHttp.d.ts +24 -0
- package/dist/utc/parse/parseHttp.js +51 -0
- package/dist/utc/parse/parseMicrosecondFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseMicrosecondFromUtc.js +26 -0
- package/dist/utc/parse/parseMillisecondFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseMillisecondFromUtc.js +26 -0
- package/dist/utc/parse/parseMinuteFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseMinuteFromUtc.js +26 -0
- package/dist/utc/parse/parseMonthFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseMonthFromUtc.js +26 -0
- package/dist/utc/parse/parseNanosecondFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseNanosecondFromUtc.js +26 -0
- package/dist/utc/parse/parseSecondFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseSecondFromUtc.js +26 -0
- package/dist/utc/parse/parseTimeFromUtc.d.ts +18 -0
- package/dist/utc/parse/parseTimeFromUtc.js +35 -0
- package/dist/utc/parse/parseUnitFromUtc.d.ts +21 -0
- package/dist/utc/parse/parseUnitFromUtc.js +55 -0
- package/dist/utc/parse/parseWeekFromUtc.d.ts +16 -0
- package/dist/utc/parse/parseWeekFromUtc.js +30 -0
- package/dist/utc/parse/parseYearFromUtc.d.ts +13 -0
- package/dist/utc/parse/parseYearFromUtc.js +26 -0
- package/dist/utc/validate/index.d.ts +2 -0
- package/dist/utc/validate/index.js +2 -0
- package/dist/utc/validate/isValidUtc.d.ts +17 -0
- package/dist/utc/validate/isValidUtc.js +34 -0
- package/dist/utc/validate/isValidUtcRange.d.ts +25 -0
- package/dist/utc/validate/isValidUtcRange.js +44 -0
- package/dist/zoned/calculate/addZoned.d.ts +50 -0
- package/dist/zoned/calculate/addZoned.js +88 -0
- package/dist/zoned/calculate/addZonedBusinessDays.d.ts +18 -0
- package/dist/zoned/calculate/addZonedBusinessDays.js +30 -0
- package/dist/zoned/calculate/clampZoned.d.ts +20 -0
- package/dist/zoned/calculate/clampZoned.js +48 -0
- package/dist/zoned/calculate/closestZonedTo.d.ts +18 -0
- package/dist/zoned/calculate/closestZonedTo.js +46 -0
- package/dist/zoned/calculate/cycleZoned.d.ts +44 -0
- package/dist/zoned/calculate/cycleZoned.js +58 -0
- package/dist/zoned/calculate/diffZoned.d.ts +39 -0
- package/dist/zoned/calculate/diffZoned.js +76 -0
- package/dist/zoned/calculate/diffZonedAsDuration.d.ts +36 -0
- package/dist/zoned/calculate/diffZonedAsDuration.js +55 -0
- package/dist/zoned/calculate/endOfQuarterForZoned.d.ts +25 -0
- package/dist/zoned/calculate/endOfQuarterForZoned.js +50 -0
- package/dist/zoned/calculate/endOfZoned.d.ts +28 -0
- package/dist/zoned/calculate/endOfZoned.js +130 -0
- package/dist/zoned/calculate/getHoursInZonedDay.d.ts +22 -0
- package/dist/zoned/calculate/getHoursInZonedDay.js +45 -0
- package/dist/zoned/calculate/getLocaleZonedDayOfWeek.d.ts +20 -0
- package/dist/zoned/calculate/getLocaleZonedDayOfWeek.js +36 -0
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.d.ts +44 -0
- package/dist/zoned/calculate/getLocaleZonedEndOfWeek.js +68 -0
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.d.ts +44 -0
- package/dist/zoned/calculate/getLocaleZonedStartOfWeek.js +68 -0
- package/dist/zoned/calculate/getQuarterForZoned.d.ts +15 -0
- package/dist/zoned/calculate/getQuarterForZoned.js +28 -0
- package/dist/zoned/calculate/index.d.ts +23 -0
- package/dist/zoned/calculate/index.js +23 -0
- package/dist/zoned/calculate/maxZoned.d.ts +15 -0
- package/dist/zoned/calculate/maxZoned.js +35 -0
- package/dist/zoned/calculate/minZoned.d.ts +15 -0
- package/dist/zoned/calculate/minZoned.js +35 -0
- package/dist/zoned/calculate/roundZoned.d.ts +23 -0
- package/dist/zoned/calculate/roundZoned.js +55 -0
- package/dist/zoned/calculate/setZoned.d.ts +39 -0
- package/dist/zoned/calculate/setZoned.js +56 -0
- package/dist/zoned/calculate/sortZoned.d.ts +17 -0
- package/dist/zoned/calculate/sortZoned.js +36 -0
- package/dist/zoned/calculate/startOfQuarterForZoned.d.ts +25 -0
- package/dist/zoned/calculate/startOfQuarterForZoned.js +40 -0
- package/dist/zoned/calculate/startOfZoned.d.ts +27 -0
- package/dist/zoned/calculate/startOfZoned.js +122 -0
- package/dist/zoned/calculate/subtractZoned.d.ts +47 -0
- package/dist/zoned/calculate/subtractZoned.js +82 -0
- package/dist/zoned/calculate/subtractZonedBusinessDays.d.ts +18 -0
- package/dist/zoned/calculate/subtractZonedBusinessDays.js +28 -0
- package/dist/zoned/chop/chopZonedDate.d.ts +13 -0
- package/dist/zoned/chop/chopZonedDate.js +24 -0
- package/dist/zoned/chop/chopZonedDateTime.d.ts +13 -0
- package/dist/zoned/chop/chopZonedDateTime.js +26 -0
- package/dist/zoned/chop/chopZonedMilliseconds.d.ts +13 -0
- package/dist/zoned/chop/chopZonedMilliseconds.js +26 -0
- package/dist/zoned/chop/chopZonedSeconds.d.ts +13 -0
- package/dist/zoned/chop/chopZonedSeconds.js +26 -0
- package/dist/zoned/chop/chopZonedTime.d.ts +13 -0
- package/dist/zoned/chop/chopZonedTime.js +24 -0
- package/dist/zoned/chop/chopZonedTimezone.d.ts +13 -0
- package/dist/zoned/chop/chopZonedTimezone.js +24 -0
- package/dist/zoned/chop/index.d.ts +6 -0
- package/dist/zoned/chop/index.js +6 -0
- package/dist/zoned/compare/areZonedEqual.d.ts +15 -0
- package/dist/zoned/compare/areZonedEqual.js +45 -0
- package/dist/zoned/compare/areZonedEqualBy.d.ts +30 -0
- package/dist/zoned/compare/areZonedEqualBy.js +49 -0
- package/dist/zoned/compare/index.d.ts +12 -0
- package/dist/zoned/compare/index.js +12 -0
- package/dist/zoned/compare/isAfterZoned.d.ts +15 -0
- package/dist/zoned/compare/isAfterZoned.js +36 -0
- package/dist/zoned/compare/isBeforeZoned.d.ts +15 -0
- package/dist/zoned/compare/isBeforeZoned.js +36 -0
- package/dist/zoned/compare/isBetweenZoned.d.ts +19 -0
- package/dist/zoned/compare/isBetweenZoned.js +55 -0
- package/dist/zoned/compare/isInDaylightSaving.d.ts +25 -0
- package/dist/zoned/compare/isInDaylightSaving.js +68 -0
- package/dist/zoned/compare/isZonedBusinessDay.d.ts +22 -0
- package/dist/zoned/compare/isZonedBusinessDay.js +34 -0
- package/dist/zoned/compare/isZonedFuture.d.ts +18 -0
- package/dist/zoned/compare/isZonedFuture.js +31 -0
- package/dist/zoned/compare/isZonedPast.d.ts +18 -0
- package/dist/zoned/compare/isZonedPast.js +31 -0
- package/dist/zoned/compare/isZonedRelativeDay.d.ts +25 -0
- package/dist/zoned/compare/isZonedRelativeDay.js +40 -0
- package/dist/zoned/compare/isZonedThisUnit.d.ts +28 -0
- package/dist/zoned/compare/isZonedThisUnit.js +52 -0
- package/dist/zoned/compare/isZonedWeekend.d.ts +23 -0
- package/dist/zoned/compare/isZonedWeekend.js +39 -0
- package/dist/zoned/convert/convertPlainDateTimeToZoned.d.ts +26 -0
- package/dist/zoned/convert/convertPlainDateTimeToZoned.js +42 -0
- package/dist/zoned/convert/convertZonedToCalendar.d.ts +49 -0
- package/dist/zoned/convert/convertZonedToCalendar.js +67 -0
- package/dist/zoned/convert/convertZonedToPlainDateTime.d.ts +13 -0
- package/dist/zoned/convert/convertZonedToPlainDateTime.js +25 -0
- package/dist/zoned/convert/convertZonedToUnix.d.ts +17 -0
- package/dist/zoned/convert/convertZonedToUnix.js +34 -0
- package/dist/zoned/convert/convertZonedToUtc.d.ts +13 -0
- package/dist/zoned/convert/convertZonedToUtc.js +25 -0
- package/dist/zoned/convert/convertZonedToZoned.d.ts +14 -0
- package/dist/zoned/convert/convertZonedToZoned.js +27 -0
- package/dist/zoned/convert/index.d.ts +6 -0
- package/dist/zoned/convert/index.js +6 -0
- package/dist/zoned/format/formatCalendarZoned.d.ts +34 -0
- package/dist/zoned/format/formatCalendarZoned.js +65 -0
- package/dist/zoned/format/formatRelativeZoned.d.ts +44 -0
- package/dist/zoned/format/formatRelativeZoned.js +79 -0
- package/dist/zoned/format/formatRfc2822.d.ts +22 -0
- package/dist/zoned/format/formatRfc2822.js +47 -0
- package/dist/zoned/format/formatRfc3339.d.ts +24 -0
- package/dist/zoned/format/formatRfc3339.js +37 -0
- package/dist/zoned/format/formatTimeZoneName.d.ts +39 -0
- package/dist/zoned/format/formatTimeZoneName.js +56 -0
- package/dist/zoned/format/formatZonedDateTime.d.ts +17 -0
- package/dist/zoned/format/formatZonedDateTime.js +32 -0
- package/dist/zoned/format/formatZonedRange.d.ts +18 -0
- package/dist/zoned/format/formatZonedRange.js +48 -0
- package/dist/zoned/format/formatZonedToParts.d.ts +29 -0
- package/dist/zoned/format/formatZonedToParts.js +48 -0
- package/dist/zoned/format/index.d.ts +8 -0
- package/dist/zoned/format/index.js +8 -0
- package/dist/zoned/get/getDstTransitions.d.ts +36 -0
- package/dist/zoned/get/getDstTransitions.js +62 -0
- package/dist/zoned/get/getSystemTimeZone.d.ts +11 -0
- package/dist/zoned/get/getSystemTimeZone.js +19 -0
- package/dist/zoned/get/getTimeZoneOffset.d.ts +21 -0
- package/dist/zoned/get/getTimeZoneOffset.js +33 -0
- package/dist/zoned/get/getTimeZones.d.ts +12 -0
- package/dist/zoned/get/getTimeZones.js +19 -0
- package/dist/zoned/get/getZonedDay.d.ts +13 -0
- package/dist/zoned/get/getZonedDay.js +26 -0
- package/dist/zoned/get/getZonedDayOfWeek.d.ts +14 -0
- package/dist/zoned/get/getZonedDayOfWeek.js +26 -0
- package/dist/zoned/get/getZonedHour.d.ts +13 -0
- package/dist/zoned/get/getZonedHour.js +26 -0
- package/dist/zoned/get/getZonedMicrosecond.d.ts +13 -0
- package/dist/zoned/get/getZonedMicrosecond.js +26 -0
- package/dist/zoned/get/getZonedMillisecond.d.ts +13 -0
- package/dist/zoned/get/getZonedMillisecond.js +26 -0
- package/dist/zoned/get/getZonedMinute.d.ts +13 -0
- package/dist/zoned/get/getZonedMinute.js +26 -0
- package/dist/zoned/get/getZonedMonth.d.ts +13 -0
- package/dist/zoned/get/getZonedMonth.js +26 -0
- package/dist/zoned/get/getZonedNanosecond.d.ts +13 -0
- package/dist/zoned/get/getZonedNanosecond.js +26 -0
- package/dist/zoned/get/getZonedNow.d.ts +17 -0
- package/dist/zoned/get/getZonedNow.js +31 -0
- package/dist/zoned/get/getZonedNowUnit.d.ts +16 -0
- package/dist/zoned/get/getZonedNowUnit.js +72 -0
- package/dist/zoned/get/getZonedSecond.d.ts +13 -0
- package/dist/zoned/get/getZonedSecond.js +26 -0
- package/dist/zoned/get/getZonedToday.d.ts +13 -0
- package/dist/zoned/get/getZonedToday.js +26 -0
- package/dist/zoned/get/getZonedWeekOfYear.d.ts +14 -0
- package/dist/zoned/get/getZonedWeekOfYear.js +26 -0
- package/dist/zoned/get/getZonedYear.d.ts +13 -0
- package/dist/zoned/get/getZonedYear.js +26 -0
- package/dist/zoned/get/index.d.ts +18 -0
- package/dist/zoned/get/index.js +18 -0
- package/dist/zoned/index.d.ts +11 -0
- package/dist/zoned/index.js +12 -0
- package/dist/zoned/interval/index.d.ts +18 -0
- package/dist/zoned/interval/index.js +18 -0
- package/dist/zoned/interval/intervalAbutsZoned.d.ts +30 -0
- package/dist/zoned/interval/intervalAbutsZoned.js +74 -0
- package/dist/zoned/interval/intervalContainsZoned.d.ts +31 -0
- package/dist/zoned/interval/intervalContainsZoned.js +70 -0
- package/dist/zoned/interval/intervalCountZoned.d.ts +39 -0
- package/dist/zoned/interval/intervalCountZoned.js +82 -0
- package/dist/zoned/interval/intervalDifferenceZoned.d.ts +38 -0
- package/dist/zoned/interval/intervalDifferenceZoned.js +94 -0
- package/dist/zoned/interval/intervalDivideEquallyZoned.d.ts +35 -0
- package/dist/zoned/interval/intervalDivideEquallyZoned.js +80 -0
- package/dist/zoned/interval/intervalEngulfsZoned.d.ts +30 -0
- package/dist/zoned/interval/intervalEngulfsZoned.js +65 -0
- package/dist/zoned/interval/intervalFromDurationZoned.d.ts +45 -0
- package/dist/zoned/interval/intervalFromDurationZoned.js +85 -0
- package/dist/zoned/interval/intervalIntersectionZoned.d.ts +36 -0
- package/dist/zoned/interval/intervalIntersectionZoned.js +77 -0
- package/dist/zoned/interval/intervalLengthZoned.d.ts +31 -0
- package/dist/zoned/interval/intervalLengthZoned.js +61 -0
- package/dist/zoned/interval/intervalOverlappingDaysZoned.d.ts +42 -0
- package/dist/zoned/interval/intervalOverlappingDaysZoned.js +89 -0
- package/dist/zoned/interval/intervalSplitAtZoned.d.ts +36 -0
- package/dist/zoned/interval/intervalSplitAtZoned.js +84 -0
- package/dist/zoned/interval/intervalUnionZoned.d.ts +38 -0
- package/dist/zoned/interval/intervalUnionZoned.js +79 -0
- package/dist/zoned/interval/intervalXorAllZoned.d.ts +37 -0
- package/dist/zoned/interval/intervalXorAllZoned.js +108 -0
- package/dist/zoned/interval/intervalXorZoned.d.ts +39 -0
- package/dist/zoned/interval/intervalXorZoned.js +118 -0
- package/dist/zoned/interval/intervalsOverlapZoned.d.ts +27 -0
- package/dist/zoned/interval/intervalsOverlapZoned.js +62 -0
- package/dist/zoned/interval/mergeIntervalsZoned.d.ts +36 -0
- package/dist/zoned/interval/mergeIntervalsZoned.js +77 -0
- package/dist/zoned/interval/splitIntervalByUnitZoned.d.ts +31 -0
- package/dist/zoned/interval/splitIntervalByUnitZoned.js +77 -0
- package/dist/zoned/interval/validate/index.d.ts +2 -0
- package/dist/zoned/interval/validate/index.js +2 -0
- package/dist/zoned/interval/validate/isValidCalendarZonedInterval.d.ts +31 -0
- package/dist/zoned/interval/validate/isValidCalendarZonedInterval.js +45 -0
- package/dist/zoned/interval/validate/isValidZonedInterval.d.ts +23 -0
- package/dist/zoned/interval/validate/isValidZonedInterval.js +44 -0
- package/dist/zoned/map/index.d.ts +2 -0
- package/dist/zoned/map/index.js +2 -0
- package/dist/zoned/map/mapZonedDatesInRange.d.ts +16 -0
- package/dist/zoned/map/mapZonedDatesInRange.js +56 -0
- package/dist/zoned/map/mapZonedHoursInDay.d.ts +23 -0
- package/dist/zoned/map/mapZonedHoursInDay.js +47 -0
- package/dist/zoned/parse/getZonedOffset.d.ts +17 -0
- package/dist/zoned/parse/getZonedOffset.js +29 -0
- package/dist/zoned/parse/getZonedOffsetAs.d.ts +29 -0
- package/dist/zoned/parse/getZonedOffsetAs.js +44 -0
- package/dist/zoned/parse/index.d.ts +20 -0
- package/dist/zoned/parse/index.js +20 -0
- package/dist/zoned/parse/parseDateFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseDateFromZoned.js +26 -0
- package/dist/zoned/parse/parseDateTimeFromZoned.d.ts +14 -0
- package/dist/zoned/parse/parseDateTimeFromZoned.js +27 -0
- package/dist/zoned/parse/parseDayFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseDayFromZoned.js +26 -0
- package/dist/zoned/parse/parseDayOfWeekFromZoned.d.ts +14 -0
- package/dist/zoned/parse/parseDayOfWeekFromZoned.js +27 -0
- package/dist/zoned/parse/parseHourFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseHourFromZoned.js +26 -0
- package/dist/zoned/parse/parseMicrosecondFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseMicrosecondFromZoned.js +26 -0
- package/dist/zoned/parse/parseMillisecondFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseMillisecondFromZoned.js +26 -0
- package/dist/zoned/parse/parseMinuteFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseMinuteFromZoned.js +26 -0
- package/dist/zoned/parse/parseMonthFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseMonthFromZoned.js +26 -0
- package/dist/zoned/parse/parseNanosecondFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseNanosecondFromZoned.js +26 -0
- package/dist/zoned/parse/parseRfc2822.d.ts +26 -0
- package/dist/zoned/parse/parseRfc2822.js +71 -0
- package/dist/zoned/parse/parseRfc3339.d.ts +23 -0
- package/dist/zoned/parse/parseRfc3339.js +42 -0
- package/dist/zoned/parse/parseSecondFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseSecondFromZoned.js +26 -0
- package/dist/zoned/parse/parseTimeFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseTimeFromZoned.js +26 -0
- package/dist/zoned/parse/parseTimeZoneFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseTimeZoneFromZoned.js +25 -0
- package/dist/zoned/parse/parseUnitFromZoned.d.ts +19 -0
- package/dist/zoned/parse/parseUnitFromZoned.js +71 -0
- package/dist/zoned/parse/parseWeekFromZoned.d.ts +17 -0
- package/dist/zoned/parse/parseWeekFromZoned.js +30 -0
- package/dist/zoned/parse/parseYearFromZoned.d.ts +13 -0
- package/dist/zoned/parse/parseYearFromZoned.js +26 -0
- package/dist/zoned/validate/hasDaylightSaving.d.ts +17 -0
- package/dist/zoned/validate/hasDaylightSaving.js +43 -0
- package/dist/zoned/validate/index.d.ts +5 -0
- package/dist/zoned/validate/index.js +5 -0
- package/dist/zoned/validate/isValidCalendarZonedDateTime.d.ts +30 -0
- package/dist/zoned/validate/isValidCalendarZonedDateTime.js +41 -0
- package/dist/zoned/validate/isValidTimeZone.d.ts +15 -0
- package/dist/zoned/validate/isValidTimeZone.js +33 -0
- package/dist/zoned/validate/isValidZonedDateTime.d.ts +22 -0
- package/dist/zoned/validate/isValidZonedDateTime.js +39 -0
- package/dist/zoned/validate/isValidZonedRange.d.ts +26 -0
- package/dist/zoned/validate/isValidZonedRange.js +43 -0
- package/package.json +113 -0
- package/skills/_artifacts/domain_map.yaml +547 -0
- package/skills/_artifacts/skill_spec.md +67 -0
- package/skills/_artifacts/skill_tree.yaml +278 -0
- package/skills/api-expansion-workflow/SKILL.md +52 -0
- package/skills/app-integration/SKILL.md +38 -0
- package/skills/calculate-dates/SKILL.md +432 -0
- package/skills/compare-dates/SKILL.md +412 -0
- package/skills/convert-types/SKILL.md +305 -0
- package/skills/durations/SKILL.md +418 -0
- package/skills/format-date-time/SKILL.md +486 -0
- package/skills/format-date-time/references/format-api.md +34 -0
- package/skills/format-relative-time/SKILL.md +223 -0
- package/skills/get-current/SKILL.md +229 -0
- package/skills/interval-ops/SKILL.md +432 -0
- package/skills/issue-creation/SKILL.md +118 -0
- package/skills/lint-package-suggestion/SKILL.md +37 -0
- package/skills/new-method-implementation/SKILL.md +71 -0
- package/skills/parse-date-time/SKILL.md +349 -0
- package/skills/pr-contribution/SKILL.md +180 -0
- package/skills/unit-test-generation/SKILL.md +56 -0
- package/skills/validate-dates/SKILL.md +438 -0
- package/skills/zoned-date-ops/SKILL.md +422 -0
- package/skills/zoned-date-ops/references/timezones.md +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,1626 @@
|
|
|
1
|
+
# @northguild/gmt
|
|
2
|
+
|
|
3
|
+
Give Me Temporal.
|
|
4
|
+
|
|
5
|
+
`@northguild/gmt` is a Temporal-first date and time library with a simple rule set:
|
|
6
|
+
|
|
7
|
+
- ISO 8601 strings in
|
|
8
|
+
- ISO 8601 strings, numbers, booleans, or arrays out
|
|
9
|
+
- no `Date`
|
|
10
|
+
- plain and zoned operations kept separate
|
|
11
|
+
|
|
12
|
+
It wraps `@js-temporal/polyfill` behind a smaller, more opinionated API aimed at the cases application code actually hits: arithmetic, comparison, parsing, formatting, unix conversions, timezone conversion, and validation.
|
|
13
|
+
|
|
14
|
+
**Status:** pre-alpha. Expect API movement while the surface is still being filled out.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @northguild/gmt
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @northguild/gmt
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Design Philosophy
|
|
27
|
+
|
|
28
|
+
GMT enforces a strict input/output contract to keep behavior predictable and auditable:
|
|
29
|
+
|
|
30
|
+
- **Explicit inputs only**: Public APIs accept clearly defined shapes — ISO 8601 date/time strings, IANA timezone identifiers, or numeric Unix epoch values (explicitly seconds or milliseconds). We do not attempt to parse arbitrary or ambiguous date formats.
|
|
31
|
+
- **Predictable outputs**: Helpers return normalized values (ISO strings, numbers, booleans, or arrays). Invalid input yields typed fallbacks (`""`, `null`, or `false`) instead of throwing.
|
|
32
|
+
- **No fuzzy parsing**: Avoid "throw everything at the wall" patterns found in permissive libraries. If you need permissive parsing, perform it outside of `@northguild/gmt` and then canonicalize to the strict shapes before calling into gmt.
|
|
33
|
+
- **Developer comfort with standards**: The library's goal is to make developers comfortable and deliberate with ISO 8601, IANA timezones, UTC instants, and Unix epochs by keeping APIs small and explicit.
|
|
34
|
+
|
|
35
|
+
## Core Rules
|
|
36
|
+
|
|
37
|
+
| Rule | Current behavior |
|
|
38
|
+
| ----------------------- | ---------------------------------------------------------------------------------- |
|
|
39
|
+
| String-first API | Public helpers consume ISO strings and return normalized strings where appropriate |
|
|
40
|
+
| Temporal-only internals | `Temporal` does the parsing and timezone math |
|
|
41
|
+
| Plain/zoned separation | `plain/*` is timezone-free, `zoned/*` is timezone-aware |
|
|
42
|
+
| No-throw public helpers | Invalid input returns a typed fallback instead of throwing |
|
|
43
|
+
|
|
44
|
+
Invalid input fallbacks are consistent across the library:
|
|
45
|
+
|
|
46
|
+
- string-returning helpers return `""`
|
|
47
|
+
- number-returning helpers return `null`
|
|
48
|
+
- boolean-returning helpers return `false`
|
|
49
|
+
- array-returning helpers return `[]`
|
|
50
|
+
|
|
51
|
+
## Testing
|
|
52
|
+
|
|
53
|
+
Every function is exercised across **17 locales** and a full IANA timezone matrix. The CI pipeline runs the complete suite in **20 environments** — 2 Node versions (22, 24) × 10 timezones spanning every UTC offset band from Pacific/Niue (−11:00) to Pacific/Apia (+13:00):
|
|
54
|
+
|
|
55
|
+
| Timezone | UTC Offset |
|
|
56
|
+
| ------------------- | --------------- |
|
|
57
|
+
| Pacific/Niue | −11:00 |
|
|
58
|
+
| America/New_York | −05:00 / −04:00 |
|
|
59
|
+
| UTC | ±00:00 |
|
|
60
|
+
| Europe/London | ±00:00 / +01:00 |
|
|
61
|
+
| Asia/Kolkata | +05:30 |
|
|
62
|
+
| Asia/Kathmandu | +05:45 |
|
|
63
|
+
| Asia/Shanghai | +08:00 |
|
|
64
|
+
| Australia/Lord_Howe | +10:00 / +11:00 |
|
|
65
|
+
| Pacific/Chatham | +12:45 / +13:45 |
|
|
66
|
+
| Pacific/Apia | +13:00 / +14:00 |
|
|
67
|
+
|
|
68
|
+
This guarantees that DST transitions, leap seconds, half-hour offsets, and locale-specific weekend boundaries are all covered — not just the happy path.
|
|
69
|
+
|
|
70
|
+
### Testing strategy
|
|
71
|
+
|
|
72
|
+
GMT's test suite balances **thoroughness** against **maintenance burden** by testing behavior, not permutations.
|
|
73
|
+
|
|
74
|
+
**What we test exhaustively:**
|
|
75
|
+
|
|
76
|
+
- **17-locale matrix** — every locale-aware function is exercised across all 17 `MustTestLocales` (en-US, en-GB, de-DE, fr-FR, es-ES, it-IT, pt-PT, sv-SE, zh-CN, zh-TW, ja-JP, ko-KR, ar-SA, he-IL, ru-RU, tr-TR, is-IS). This covers script direction, first-day-of-week differences, and calendar metadata.
|
|
77
|
+
- **Timezone battle matrix** — every zoned function is exercised across 10 IANA timezones spanning every UTC offset band from Pacific/Niue (−11:00) to Pacific/Apia (+14:00), including DST-transition and half-hour-offset zones.
|
|
78
|
+
- **Zero-length and identity cases** — every interval and arithmetic function is tested with zero-length inputs, identity operations, and boundary-adjacent values.
|
|
79
|
+
- **Invalid-input sentinels** — every public function is tested for the documented fallback behavior (`""`, `null`, `false`, `[]`) on malformed strings, wrong types, leap seconds, and inverted intervals.
|
|
80
|
+
|
|
81
|
+
**What we collapse:**
|
|
82
|
+
|
|
83
|
+
- **Non-string input tables** — functions that guard with `typeof x !== "string"` return the same sentinel for `null`, `undefined`, `123`, `true`, `[]`, and `{}`. We test one representative non-string per argument position rather than all six types × N positions. The collapse is safe because all non-string types hit the identical early-return code path.
|
|
84
|
+
- **Redundant permutations** — adjacent/disjoint/reversed interval cases that produce identical results are not duplicated across every function variant. The `plain/`, `zoned/`, `utc/`, and `unix/` families share the same mathematical behavior; each family gets the minimum set of cases needed to prove correctness.
|
|
85
|
+
|
|
86
|
+
**Result:** 15,611 tests across 527 files that exercise real behavior differences without redundant permutations. The suite runs in CI as 312,220 executions (15,611 × 2 Node versions × 10 timezones).
|
|
87
|
+
|
|
88
|
+
## How GMT is tested, vs. the libraries it targets
|
|
89
|
+
|
|
90
|
+
GMT's roadmap (see [context/roadmap](https://github.com/northguild/gmt/tree/main/context/roadmap)) is explicitly scoped against react-aria's **`@internationalized/date`**, **Luxon**, **date-fns**, and **Moment.js** — the same four libraries compared below. All numbers were verified **2026-08-22** against the exact package versions/commits below — nothing is estimated. Re-verify before citing these numbers elsewhere; library surfaces and CI configs move.
|
|
91
|
+
|
|
92
|
+
| Library | Version tested |
|
|
93
|
+
| ------------------------- | --------------------------------------- |
|
|
94
|
+
| GMT (`@northguild/gmt`) | 1.12.0 |
|
|
95
|
+
| `@internationalized/date` | 3.12.3 (`adobe/react-spectrum@5d191ab`) |
|
|
96
|
+
| Luxon | 3.7.2 (`moment/luxon@f427515`) |
|
|
97
|
+
| date-fns | 4.4.0 (`date-fns/date-fns@a0a3922`) |
|
|
98
|
+
| Moment.js | 2.30.1 (`moment/moment@cf524af`) |
|
|
99
|
+
|
|
100
|
+
| Metric | GMT | `@internationalized/date` | Luxon | date-fns | Moment.js |
|
|
101
|
+
| ------------------------------- | -------------------------------------------------- | ------------------------------ | ------------------------------------ | ----------------------------------------- | -------------------------------- |
|
|
102
|
+
| Test files | 527 | 6 | 58 / 60<br>(2 didn't run<br>locally) | 256 | 191<br>(52 core +<br>139 locale) |
|
|
103
|
+
| Individual test cases | **15,611** | 386 | 1,222 | 3,213 | 3,901 |
|
|
104
|
+
| Effective CI test<br>executions | **312,220**<br>(15,611 × 2 Node<br>× 10 timezones) | 386<br>(×1 Node) | 4,888<br>(1,222 × 4 Node) | 3,213<br>(×1 Node) | 11,703<br>(3,901 × 3 Node) |
|
|
105
|
+
| CI Node.js matrix | 22, 24 | n/a — tests<br>React 16–canary | 20, 22, 24, 25 | not explicit<br>(`node = "latest"`) | LTS, LTS-1,<br>latest |
|
|
106
|
+
| CI timezone matrix | **10 zones × 2**<br>**Node, full suite** | none found | none found | dedicated workflow,<br>zone scope unclear | 6 zones,<br>partial suite only |
|
|
107
|
+
| Locale test matrix | **17 locales**,<br>every locale fn | none found | none found | none found | none found |
|
|
108
|
+
| Real-browser CI | not yet | yes (Playwright) | not found | yes (Playwright) | not found |
|
|
109
|
+
| Maintenance | active | active | active | active | **maintenance<br>mode** |
|
|
110
|
+
|
|
111
|
+
<sub>Methodology: "Test files" and the CI/maintenance rows come from each project's public CI configuration and repository file listing. "Individual test cases" for GMT, Luxon, date-fns, and Moment.js were obtained by actually cloning the repo at the commit above, installing dependencies, running the project's own test command (`vitest run` / `jest` / `node scripts/test.js`), and reading that runner's own final summary — not grepped from source. `@internationalized/date` was run by cloning `adobe/react-spectrum` at `5d191ab`, installing dependencies, and executing `npx jest packages/@internationalized/date/tests/`, yielding 386 passing tests. Luxon (39 failures) and date-fns (46 failures) had environment-dependent local failures that don't affect the total count: Luxon's suite assumes its CI container's local time zone is `America/New_York`; date-fns's experimental native-`Temporal` code path needs a global `Temporal` Node doesn't yet provide natively. Moment.js passed cleanly (0 failed) on Node 24. Sources: [GMT](https://github.com/northguild/gmt/blob/main/.github/workflows/ci.yml) · [`@internationalized/date`](https://github.com/adobe/react-spectrum/blob/main/.circleci/config.yml) · [Luxon](https://github.com/moment/luxon/blob/master/.github/workflows/test.yml) · [date-fns](https://github.com/date-fns/date-fns/tree/main/.github/workflows) · [Moment.js](https://github.com/moment/moment/tree/develop/.github/workflows).</sub>
|
|
112
|
+
|
|
113
|
+
### Functionality parity progress
|
|
114
|
+
|
|
115
|
+
GMT's roadmap tracks parity against the same four libraries story-by-story, with each gap sourced against the specific competitor function it closes — see [context/roadmap](https://github.com/northguild/gmt/tree/main/context/roadmap) for the full, source-verified audit trail. This is a live snapshot, not a finished-parity claim: ✅ shipped, 🟡 in progress, ⏳ backlog and not yet scheduled.
|
|
116
|
+
|
|
117
|
+
| Capability | Status | Also has it |
|
|
118
|
+
| -------------------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------ |
|
|
119
|
+
| Duration type<br>(ISO 8601 parse/format/arithmetic) | ✅ Done | Luxon `Duration` |
|
|
120
|
+
| Interval/range math<br>(contains, overlap, union,<br>intersection, split, set ops) | ✅ Done | Luxon `Interval`,<br>date-fns `areIntervalsOverlapping` |
|
|
121
|
+
| DST disambiguation control<br>on construction _and_ arithmetic | ✅ Done — **differentiator** | None of the others expose<br>this on arithmetic |
|
|
122
|
+
| Locale-aware calendar helpers<br>(weekend, week start/end, day-of-week) | ✅ Done | `@internationalized/date` |
|
|
123
|
+
| Business-day arithmetic,<br>clamp/closest, time rounding | ✅ Done | `temporal-kit` |
|
|
124
|
+
| Interval rounding-out<br>(boundary count, from-duration) | ✅ Done | Luxon |
|
|
125
|
+
| Locale calendar metadata<br>(names, `hasDST`) | ✅ Done | Luxon `Info` |
|
|
126
|
+
| Overlap-day count, relative<br>rounding, DST transitions, hours-in-day | ✅ Done | date-fns, `@internationalized/date` |
|
|
127
|
+
| Field setters, token-pattern<br>parsing, named machine formats,<br>calendar-style formatting | ✅ Done | Luxon `.set()`,<br>`toRFC2822`/`toHTTP`/`toSQL`,<br>Moment `.calendar()` |
|
|
128
|
+
| Non-Gregorian calendar systems<br>(conversion + calendar-aware<br>interval/duration math) | ✅ Done | `@internationalized/date`'s<br>`toCalendar` |
|
|
129
|
+
|
|
130
|
+
<sub>Status reflects [context/roadmap/tracker.md](https://github.com/northguild/gmt/tree/main/context/roadmap/tracker.md) as of this writing.</sub>
|
|
131
|
+
|
|
132
|
+
### Where GMT stands alone
|
|
133
|
+
|
|
134
|
+
Specific, sourced claims — not a repeat of the metrics above.
|
|
135
|
+
|
|
136
|
+
| Claim | The others |
|
|
137
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
138
|
+
| Only GMT runs its **entire** suite in CI<br>under a real `TZ` env var across 10<br>real-world zones × 2 Node versions<br>(20 full-suite runs) | Luxon/`@internationalized/date`: no<br>CI timezone matrix. date-fns: zone<br>scope unclear. Moment.js: 6 zones,<br>partial suite only |
|
|
139
|
+
| Only GMT enforces a mandatory<br>17-locale test matrix on every<br>locale-aware function | No CI-level or systematic<br>locale-matrix testing found<br>in any of the four |
|
|
140
|
+
| Only GMT exposes explicit DST<br>disambiguation control on both<br>construction _and_ arithmetic | Luxon's docs call this explicitly<br>undefined; `@internationalized/date`<br>only covers construction, not arithmetic |
|
|
141
|
+
| Only GMT is Temporal-native with<br>zero `Date` usage, enforced by<br>3 dedicated lint packages | Luxon, date-fns, and Moment.js all<br>still wrap or depend on `Date` internally |
|
|
142
|
+
| GMT's effective CI test<br>executions exceed all four<br>competitors **combined**<br>by ~15× | 312,220 vs. 386 + 4,888 + 3,213<br>+ 11,703 = 20,190 |
|
|
143
|
+
|
|
144
|
+
## Package Layout
|
|
145
|
+
|
|
146
|
+
The package exports seven top-level namespaces:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import {
|
|
150
|
+
Temporal,
|
|
151
|
+
duration,
|
|
152
|
+
plain,
|
|
153
|
+
zoned,
|
|
154
|
+
unix,
|
|
155
|
+
utc,
|
|
156
|
+
regex,
|
|
157
|
+
} from "@northguild/gmt";
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- `Temporal`: re-exported from `@js-temporal/polyfill`
|
|
161
|
+
- `duration`: ISO 8601 duration string parsing, validation, and arithmetic
|
|
162
|
+
- `plain`: timezone-free helpers
|
|
163
|
+
- `zoned`: timezone-aware helpers
|
|
164
|
+
- `unix`: Unix epoch (seconds or milliseconds) helpers
|
|
165
|
+
- `utc`: UTC instant helpers
|
|
166
|
+
- `regex`: low-level regex building blocks
|
|
167
|
+
|
|
168
|
+
You can also import subpaths directly:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { addDate, getNow, formatRelativeZoned } from "@northguild/gmt";
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Quick Start
|
|
175
|
+
|
|
176
|
+
### Plain arithmetic and comparisons
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import {
|
|
180
|
+
addDate,
|
|
181
|
+
addBusinessDays,
|
|
182
|
+
subtractBusinessDays,
|
|
183
|
+
areDatesEqual,
|
|
184
|
+
diffDateTime,
|
|
185
|
+
isBeforeDateTime,
|
|
186
|
+
} from "@northguild/gmt";
|
|
187
|
+
|
|
188
|
+
addDate("2026-01-01", 90, "day");
|
|
189
|
+
// "2026-03-32" is impossible, so Temporal normalizes correctly -> "2026-04-01"
|
|
190
|
+
|
|
191
|
+
addBusinessDays("2024-03-15", 1);
|
|
192
|
+
// "2024-03-18" (skips weekend)
|
|
193
|
+
|
|
194
|
+
subtractBusinessDays("2024-03-18", 1);
|
|
195
|
+
// "2024-03-15" (skips weekend)
|
|
196
|
+
|
|
197
|
+
diffDateTime("2024-03-17T12:00:00", "2024-03-17T12:30:00", "minute");
|
|
198
|
+
// 30
|
|
199
|
+
|
|
200
|
+
areDatesEqual("2026-03-17", "2026-03-17T09:00:00");
|
|
201
|
+
// true
|
|
202
|
+
|
|
203
|
+
isBeforeDateTime("2026-03-17T09:00:00", "2026-03-17T10:00:00");
|
|
204
|
+
// true
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
`add*`/`subtract*` accept an optional `overflow` (`"constrain"` (default) | `"reject"`) to control out-of-range results (e.g. adding a month to Jan 31), and `diff*` accept optional `smallestUnit`/`roundingIncrement`/`roundingMode` to round the computed difference:
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import { addDate, diffDate } from "@northguild/gmt";
|
|
211
|
+
|
|
212
|
+
addDate("2024-01-31", { months: 1 }, { overflow: "reject" });
|
|
213
|
+
// "" — Feb 31 doesn't exist and overflow: "reject" refuses to clamp it
|
|
214
|
+
|
|
215
|
+
diffDate("2023-01-01", "2023-01-10", "week", {
|
|
216
|
+
smallestUnit: "week",
|
|
217
|
+
roundingMode: "halfExpand",
|
|
218
|
+
});
|
|
219
|
+
// 1
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`setDate`/`setDateTime`/`setTime`/`setZoned`/`setUnix`/`setUtc` set one or more fields on a value in a single atomic `.with()`-based call — the safe alternative to composing `add*` calls field-by-field, which resolves each field's overflow independently and can silently diverge on multi-field updates:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { setDate, setZoned } from "@northguild/gmt";
|
|
226
|
+
|
|
227
|
+
setDate("2024-01-31", { month: 2 });
|
|
228
|
+
// "2024-02-29" (constrain, the default, clamps to the last valid day)
|
|
229
|
+
|
|
230
|
+
setZoned(
|
|
231
|
+
"2024-11-03T01:45:00-05:00[America/New_York]",
|
|
232
|
+
{ minute: 0 },
|
|
233
|
+
{
|
|
234
|
+
disambiguation: "reject",
|
|
235
|
+
},
|
|
236
|
+
);
|
|
237
|
+
// "" — offset defaults to "ignore" so disambiguation actually fires on this fall-back overlap
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
`setZoned`/`setUnix`/`setUtc` also accept `disambiguation` and `offset` for DST gap/overlap control — see [DST Disambiguation](../../docs/dst-disambiguation.md).
|
|
241
|
+
|
|
242
|
+
`cycleDate`/`cycleDateTime`/`cycleTime`/`cycleZoned` adjust a single field and **wrap** at that field's own min/max instead of carrying into the next larger field — the datepicker-segment-editing primitive `add*` can't express, since overflowing into the next field is exactly what `add*` is for:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { addDate, cycleDate, cycleZoned } from "@northguild/gmt";
|
|
246
|
+
|
|
247
|
+
cycleDate("2024-12-15", "month", 1);
|
|
248
|
+
// "2024-01-15" — stays in the same year
|
|
249
|
+
|
|
250
|
+
addDate("2024-12-15", { months: 1 });
|
|
251
|
+
// "2025-01-15" — addDate correctly overflows into the next year instead
|
|
252
|
+
|
|
253
|
+
cycleZoned("2024-03-10T01:30:00-06:00[America/Chicago]", "hour", 1);
|
|
254
|
+
// "2024-03-10T03:30:00-05:00[America/Chicago]" — the cycled hour lands in a spring-forward
|
|
255
|
+
// gap; disambiguation ("compatible" by default) resolves it the same way setZoned does
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`cycleZoned` also accepts `disambiguation` and `offset` (default `offset: "ignore"`) for the same DST gap/overlap control as `setZoned` — see [DST Disambiguation](../../docs/dst-disambiguation.md). `options.round` on any of the four steps to the next multiple of `amount` rather than rounding to the nearest one, matching `@internationalized/date`'s `CycleOptions.round`.
|
|
259
|
+
|
|
260
|
+
`isWeekend`/`isZonedWeekend` check locale-specific weekend days (via `Intl.Locale`'s `weekInfo`) rather than assuming Saturday/Sunday:
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
import { isWeekend, isZonedWeekend } from "@northguild/gmt";
|
|
264
|
+
|
|
265
|
+
isWeekend("2024-02-03", "en-US");
|
|
266
|
+
// true (Saturday, en-US weekend is Sat/Sun)
|
|
267
|
+
|
|
268
|
+
isWeekend("2024-02-03", "he-IL");
|
|
269
|
+
// true (Saturday is also part of he-IL's Fri/Sat weekend)
|
|
270
|
+
|
|
271
|
+
isZonedWeekend("2024-02-04T10:00:00+02:00[Asia/Jerusalem]", "he-IL");
|
|
272
|
+
// false (Sunday isn't part of he-IL's weekend)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
`isBusinessDay` returns true for fixed ISO Monday–Friday business days (Mon=1 … Fri=5), locale-agnostic and with no holiday calendar. It's the complement to locale-aware `isWeekend` and matches the boundary that `addBusinessDays`/`subtractBusinessDays` use:
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import { isBusinessDay } from "@northguild/gmt";
|
|
279
|
+
|
|
280
|
+
isBusinessDay("2024-02-05");
|
|
281
|
+
// true (Monday)
|
|
282
|
+
|
|
283
|
+
isBusinessDay("2024-02-10");
|
|
284
|
+
// false (Saturday)
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
`isRelativeDay`/`isThisUnit`/`isPast`/`isFuture` are now-relative predicates — `isRelativeDay` subsumes `isToday`/`isYesterday`/`isTomorrow`, `isThisUnit` subsumes `isThisWeek`/`isThisMonth`/`isThisYear`. They compare against `getToday()`, so they depend on the **system clock and system timeZone**; the zoned variants (`isZonedRelativeDay`, `isZonedThisUnit`, `isZonedPast`, `isZonedFuture`) resolve "today"/"now" in the value's own timeZone instead, for deterministic results regardless of the host machine's timeZone:
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { isRelativeDay, isThisUnit, isPast, isFuture } from "@northguild/gmt";
|
|
291
|
+
|
|
292
|
+
isRelativeDay("2024-03-15", 0);
|
|
293
|
+
// true, if today is 2024-03-15 ("isToday")
|
|
294
|
+
|
|
295
|
+
isThisUnit("2024-02-26", "week", "fr-FR");
|
|
296
|
+
// locale-aware week boundary — fr-FR weeks start Monday
|
|
297
|
+
|
|
298
|
+
isPast("2024-03-14");
|
|
299
|
+
// true, if today is 2024-03-15 (strictly before, not on-or-before)
|
|
300
|
+
|
|
301
|
+
isFuture("2024-03-16");
|
|
302
|
+
// true, if today is 2024-03-15 (strictly after, not on-or-before)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
`nextWeekday`/`previousWeekday` find the next/previous occurrence of a given ISO day of week (1 = Monday … 7 = Sunday, matching `getDayOfWeek`) on or after/before a date, replacing date-fns's sixteen `next*`/`previous*` functions with two parameterized calls. `options.inclusive` (default `false`) controls what happens when the input already falls on the target day — `false` advances/retreats a full week, matching date-fns:
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
import { nextWeekday, previousWeekday } from "@northguild/gmt";
|
|
309
|
+
|
|
310
|
+
nextWeekday("2024-03-13", 5);
|
|
311
|
+
// "2024-03-15" (Wednesday -> next Friday)
|
|
312
|
+
|
|
313
|
+
nextWeekday("2024-03-15", 5);
|
|
314
|
+
// "2024-03-22" (already a Friday -> advances a full week by default)
|
|
315
|
+
|
|
316
|
+
nextWeekday("2024-03-15", 5, { inclusive: true });
|
|
317
|
+
// "2024-03-15" (already a Friday -> returned as-is)
|
|
318
|
+
|
|
319
|
+
previousWeekday("2024-03-13", 5);
|
|
320
|
+
// "2024-03-08" (Wednesday -> previous Friday)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import { isZonedRelativeDay, isZonedPast } from "@northguild/gmt";
|
|
325
|
+
|
|
326
|
+
isZonedRelativeDay("2024-03-15T10:00:00-04:00[America/New_York]", 0);
|
|
327
|
+
// "today" resolved in America/New_York, not the host's system timeZone
|
|
328
|
+
|
|
329
|
+
isZonedPast("2020-01-01T00:00:00Z[UTC]");
|
|
330
|
+
// true — compares the exact instant, not just the calendar day
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`clampDate` restricts a date to a range, and `closestDateTo` finds the nearest candidate by calendar distance:
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
import { clampDate, closestDateTo } from "@northguild/gmt";
|
|
337
|
+
|
|
338
|
+
clampDate("2024-02-01", "2024-03-01", "2024-03-31");
|
|
339
|
+
// "2024-03-01"
|
|
340
|
+
|
|
341
|
+
closestDateTo("2024-03-15", ["2024-03-01", "2024-03-20", "2024-03-18"]);
|
|
342
|
+
// "2024-03-18"
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
`getLocaleStartOfWeek`/`getLocaleEndOfWeek` (and their zoned equivalents) compute week boundaries from the locale's first day of week, instead of an ISO-Monday default:
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
import { getLocaleStartOfWeek, getLocaleEndOfWeek } from "@northguild/gmt";
|
|
349
|
+
|
|
350
|
+
getLocaleStartOfWeek("2024-02-29", "en-US");
|
|
351
|
+
// "2024-02-25" (Sunday, en-US weeks start Sunday)
|
|
352
|
+
|
|
353
|
+
getLocaleStartOfWeek("2024-02-29", "fr-FR");
|
|
354
|
+
// "2024-02-26" (Monday, fr-FR weeks start Monday)
|
|
355
|
+
|
|
356
|
+
getLocaleEndOfWeek("2024-02-29", "en-US");
|
|
357
|
+
// "2024-03-02" (Saturday)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
`getLocaleDayOfWeek`/`getLocaleZonedDayOfWeek` return a locale-relative day-of-week index (0 = first day of the locale's week):
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
import { getLocaleDayOfWeek, getLocaleZonedDayOfWeek } from "@northguild/gmt";
|
|
364
|
+
|
|
365
|
+
getLocaleDayOfWeek("2024-02-25", "en-US");
|
|
366
|
+
// 0 (Sunday = first day of en-US week)
|
|
367
|
+
|
|
368
|
+
getLocaleDayOfWeek("2024-02-26", "fr-FR");
|
|
369
|
+
// 0 (Monday = first day of fr-FR week)
|
|
370
|
+
|
|
371
|
+
getLocaleDayOfWeek("2024-02-24", "he-IL");
|
|
372
|
+
// 0 (Saturday = first day of he-IL week)
|
|
373
|
+
|
|
374
|
+
getLocaleZonedDayOfWeek("2024-02-25T12:00:00+00:00[UTC]", "en-US");
|
|
375
|
+
// 0
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
`getLocaleEraNames`/`getLocaleMonthNames`/`getLocaleWeekdayNames`/`getLocaleMeridiems` return standalone, locale-aware calendar names with no date value required — the GMT equivalents of Luxon's `Info.eras`/`Info.months`/`Info.weekdays`/`Info.meridiems`:
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
import {
|
|
382
|
+
getLocaleEraNames,
|
|
383
|
+
getLocaleMonthNames,
|
|
384
|
+
getLocaleWeekdayNames,
|
|
385
|
+
getLocaleMeridiems,
|
|
386
|
+
} from "@northguild/gmt";
|
|
387
|
+
|
|
388
|
+
getLocaleEraNames("en-US");
|
|
389
|
+
// ["Before Christ", "Anno Domini"]
|
|
390
|
+
|
|
391
|
+
getLocaleEraNames("ja-JP", "short");
|
|
392
|
+
// ["紀元前", "西暦"]
|
|
393
|
+
|
|
394
|
+
getLocaleMonthNames("en-US");
|
|
395
|
+
// ["January", "February", ... "December"]
|
|
396
|
+
|
|
397
|
+
getLocaleMonthNames("de-DE", "short");
|
|
398
|
+
// ["Jan", "Feb", "Mär", ... "Dez"]
|
|
399
|
+
|
|
400
|
+
getLocaleWeekdayNames("en-US");
|
|
401
|
+
// ["Sunday", "Monday", ... "Saturday"] (locale-first-day order)
|
|
402
|
+
|
|
403
|
+
getLocaleWeekdayNames("fr-FR");
|
|
404
|
+
// ["lundi", "mardi", ... "dimanche"]
|
|
405
|
+
|
|
406
|
+
getLocaleMeridiems("en-US");
|
|
407
|
+
// ["AM", "PM"]
|
|
408
|
+
|
|
409
|
+
getLocaleMeridiems("zh-CN");
|
|
410
|
+
// ["上午", "下午"]
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
`getLocaleWeekdayNames` returns names in the locale's first-day order, consistent with `getLocaleDayOfWeek` (index 0 is the locale's first day of the week). All four delegate to the host runtime's `Intl` data, so their output depends on the runtime's ICU build.
|
|
414
|
+
|
|
415
|
+
### Parsing
|
|
416
|
+
|
|
417
|
+
`parseDateWithPattern`/`parseDateTimeWithPattern`/`parseTimeWithPattern` decode a known, fixed producer format — a CSV column, a legacy API field, or a partially-typed form value — against a caller-supplied token pattern. This is for **decoding**, not display: the pattern hard-codes field order, so `formatDate`/`formatDateToParts` remain the correct choice for locale-correct output.
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import {
|
|
421
|
+
parseDateWithPattern,
|
|
422
|
+
parseDateTimeWithPattern,
|
|
423
|
+
parseTimeWithPattern,
|
|
424
|
+
} from "@northguild/gmt";
|
|
425
|
+
|
|
426
|
+
parseDateWithPattern("03/15/2024", "MM/dd/yyyy");
|
|
427
|
+
// "2024-03-15"
|
|
428
|
+
|
|
429
|
+
parseDateTimeWithPattern("15-Mar-2024 14:30", "dd-MMM-yyyy HH:mm");
|
|
430
|
+
// "2024-03-15T14:30:00"
|
|
431
|
+
|
|
432
|
+
parseTimeWithPattern("02:30:45 PM", "hh:mm:ss a");
|
|
433
|
+
// "14:30:45"
|
|
434
|
+
|
|
435
|
+
parseDateWithPattern("02/31/2024", "MM/dd/yyyy");
|
|
436
|
+
// "" — shape-valid but not a real date; Temporal validates after the regex match
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Supported tokens include `yyyy`/`MM`/`dd`/`HH`/`mm`/`ss`/`SSS` for fixed-width fields, `M`/`d`/`H`/`h`/`m`/`s` for variable-width, `MMMM`/`MMM`/`EEEE`/`EEE`/`a`/`GGGG`/`GG` for locale-aware names, and `'single quotes'` for literal text. A `locale` parameter (default `"en-US"`) controls name-token matching. Invalid input, no-match, and malformed patterns all return `""`.
|
|
440
|
+
|
|
441
|
+
### Calendar systems
|
|
442
|
+
|
|
443
|
+
GMT's `CalendarSystem` type (`"gregorian" | "hebrew" | "islamic-civil" | "islamic-tabular" | "islamic-umalqura" | "japanese" | "buddhist" | "taiwan" | "persian" | "indian" | "ethiopic" | "ethiopic-amete-alem" | "coptic"`, extended by later stories) and `convertDateToCalendar` express a date in a non-Gregorian calendar system, built almost entirely on Temporal's native calendar support — no bundled leap-year tables or ported arithmetic, with one deliberate exception (the Ethiopic family, covered below).
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
import { convertDateToCalendar } from "@northguild/gmt";
|
|
447
|
+
|
|
448
|
+
convertDateToCalendar("2024-10-03", "hebrew");
|
|
449
|
+
// "5785-01-01[u-ca=hebrew]" — Rosh Hashanah 5785
|
|
450
|
+
|
|
451
|
+
convertDateToCalendar("5785-01-01[u-ca=hebrew]", "gregorian");
|
|
452
|
+
// "2024-10-03" — round-trips back
|
|
453
|
+
|
|
454
|
+
convertDateToCalendar("2024-10-03", "islamic-umalqura");
|
|
455
|
+
// "1446-03-30[u-ca=islamic-umalqura]" — Saudi Umm al-Qura calendar
|
|
456
|
+
|
|
457
|
+
convertDateToCalendar("invalid", "hebrew");
|
|
458
|
+
// ""
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
The output string shape is the key design decision here, and it deliberately **diverges from Temporal's own** `[u-ca=...]` convention. Temporal's `Temporal.PlainDate.prototype.toString()` always keeps the ISO/proleptic-Gregorian year-month-day digits and only tags the calendar (`"2024-10-03[u-ca=hebrew]"` — still literally October 3rd's Gregorian digits). That hides the calendar's own fields behind calendar-aware accessors, which GMT's string-only contract has no place for. GMT's annotated string instead carries the **calendar-native** year/month/day — Hebrew year 5785, not 2024 — so the calendar-system concept is visible directly in the string, not just in an object property. A plain, unannotated ISO string is always treated as (and always produced for) the `"gregorian"` calendar, so every existing GMT function keeps working unchanged.
|
|
462
|
+
|
|
463
|
+
Hebrew years can run 12 or 13 months (7 leap years per 19-year Metonic cycle insert a 13th month, Adar I, before the regular Adar); `convertDateToCalendar` resolves this the same way Temporal does internally, via ordinal month numbers (`1`-`13`) rather than fixed month names, so no month-counting logic lives in GMT itself.
|
|
464
|
+
|
|
465
|
+
Three Islamic (Hijri) calendar variants are supported, and they are **not interchangeable** — each resolves the same Gregorian date to different calendar-native digits:
|
|
466
|
+
|
|
467
|
+
- `"islamic-civil"` — a fixed 30-year leap-year cycle, Friday epoch (`1 AH = 622-07-19`).
|
|
468
|
+
- `"islamic-tabular"` — the same style of fixed arithmetic cycle, but a Thursday epoch one day earlier (`1 AH = 622-07-18`); maps to Temporal's `"islamic-tbla"` calendar id internally, though GMT's own string annotation always reads `[u-ca=islamic-tabular]`.
|
|
469
|
+
- `"islamic-umalqura"` — the Saudi civil calendar, based on Umm al-Qura University's own published tables rather than a fixed arithmetic rule. This is **not** approximated by the tabular variant's math — `convertDateToCalendar("2020-02-24", "islamic-umalqura")` returns `"1441-06-30[u-ca=islamic-umalqura]"` while the same input under `"islamic-tabular"` returns `"1441-07-01[u-ca=islamic-tabular]"`, a genuine one-day divergence, not a rounding difference.
|
|
470
|
+
|
|
471
|
+
Five era-based solar calendars round out the set. Unlike Hebrew and the Islamic variants, none of these needed new leap-year logic — each is either Gregorian-shaped with a different year numbering layered on top, or a distinct-but-simple solar calendar, so they were materially less work than Hebrew or Islamic:
|
|
472
|
+
|
|
473
|
+
- `"buddhist"` — Gregorian day/month structure, a fixed `+543` year offset (`convertDateToCalendar("2024-10-03", "buddhist")` → `"2567-10-03[u-ca=buddhist]"`). One continuous era, no reset.
|
|
474
|
+
- `"taiwan"` — Gregorian day/month structure, year numbering reset at 1912 (the Republic of China's founding): `2024` → `"0113-10-03[u-ca=taiwan]"` (`2024 - 1911`). Dates before 1912 count backward through Temporal's inverse era instead of going negative in the way a plain offset would — `convertDateToCalendar("1911-12-31", "taiwan")` is `"0000-12-31[u-ca=taiwan]"`, not `"-0001-12-31"`.
|
|
475
|
+
- `"persian"` — a genuinely distinct solar calendar (not Gregorian-derived): own month lengths (6 months of 31 days, 5 of 30, a 29/30-day 12th month) and its own 33-year leap-year cycle (a year is leap when `(25 × year + 11) mod 33 < 8`), verified against `@internationalized/date`'s `PersianCalendar.ts` rather than assumed from the offset-only calendars above.
|
|
476
|
+
- `"indian"` — the Indian National Calendar (Saka era, epoch 78 CE). Also not offset-only: its leap-year alignment follows the Gregorian rule rather than an independent cycle — the calendar's first month is 31 days in a Gregorian leap year, 30 otherwise, which is why its Saka-year boundary (`convertDateToCalendar("2024-03-20", "indian")` → `"1945-12-30[u-ca=indian]"`, `convertDateToCalendar("2024-03-21", "indian")` → `"1946-01-01[u-ca=indian]"`) doesn't land on a fixed day-of-year every year.
|
|
477
|
+
- `"japanese"` — era-based: the year resets to `1` at each imperial era change (Meiji, Taishō, Shōwa, Heisei, Reiwa). This is the one calendar where GMT's annotated string carries an era-relative year instead of the calendar's plain native year, and needs its own explanation below.
|
|
478
|
+
|
|
479
|
+
**Why `"japanese"` gets a different string shape.** Every other supported calendar's plain `year` field is exactly what belongs in GMT's annotated string — Hebrew year 5785, Taiwan year 113, and so on are each already the single number that identifies the year. Japanese is the exception: Temporal's `.year` for the `"japanese"` calendar stays **proleptic** across era changes (it doesn't reset — `1912-07-30`, the first day of Taishō, still reports `.year === 1912`, not `1`), because Temporal's `.year` is designed to be a stable sort key, not a display value. Using it directly would silently contradict the calendar's entire reason for existing. So `convertDateToCalendar` uses Temporal's `.eraYear` (the field that _does_ reset) paired with the era name, tagged onto the annotation as `;era=<name>`:
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
convertDateToCalendar("2024-10-03", "japanese");
|
|
483
|
+
// "0006-10-03[u-ca=japanese;era=reiwa]" — year 6 of the Reiwa era, not the proleptic 2024
|
|
484
|
+
|
|
485
|
+
convertDateToCalendar("1912-07-30", "japanese");
|
|
486
|
+
// "0001-07-30[u-ca=japanese;era=taisho]" — the first day of Taishō reads year 1
|
|
487
|
+
|
|
488
|
+
convertDateToCalendar("0001-07-30[u-ca=japanese;era=taisho]", "gregorian");
|
|
489
|
+
// "1912-07-30" — round-trips back through the era + eraYear pair
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
`@internationalized/date` documents pre-Meiji (before 1868-10-23) dates as unsupported for its Japanese calendar. GMT does not replicate that restriction: since `convertDateToCalendar` is built entirely on Temporal's own calendar support rather than a ported implementation, and Temporal resolves those dates correctly under a synthetic `"japanese"` era (with an ISO-aligned `eraYear`), rejecting them would mean writing new validation solely to reproduce another library's gap rather than an actual GMT limitation. `convertDateToCalendar("1800-01-01", "japanese")` returns `"1800-01-01[u-ca=japanese;era=japanese]"` rather than `""`.
|
|
493
|
+
|
|
494
|
+
Three Ethiopic-family calendars round out the set, all sharing one 13-month structure (12 months of 30 days, plus a short Pagume/Nasie 13th month of 5 days, or 6 in a leap year) but differing in epoch:
|
|
495
|
+
|
|
496
|
+
- `"ethiopic"` — the modern Ethiopian calendar, era-based like `"japanese"`: it resets to the Amete Mihret ("Year of Mercy"/Incarnation) era at its own epoch (~AD 8), so `convertDateToCalendar("2024-10-03", "ethiopic")` returns `"2017-01-23[u-ca=ethiopic;era=ethiopic]"` — year 2017, not a 5-digit proleptic number. Dates before that epoch resolve under the Amete Alem ("Year of the World") era instead: `convertDateToCalendar("0001-01-01", "ethiopic")` → `"5493-05-08[u-ca=ethiopic;era=ethioaa]"`.
|
|
497
|
+
- `"ethiopic-amete-alem"` — the same calendar, but always counted continuously from the Amete Alem epoch (~5493 BCE), never resetting: `convertDateToCalendar("2024-10-03", "ethiopic-amete-alem")` → `"7517-01-23[u-ca=ethiopic-amete-alem]"`.
|
|
498
|
+
- `"coptic"` — the Coptic Orthodox calendar: same 13-month structure, its own epoch (the Diocletian/Martyrs era, AD 284): `convertDateToCalendar("2024-10-03", "coptic")` → `"1741-01-23[u-ca=coptic]"`.
|
|
499
|
+
|
|
500
|
+
**Why this family isn't built on Temporal's native `"ethiopic"`/`"coptic"` calendar ids, unlike every other calendar above.** `@js-temporal/polyfill`'s implementation of these two calendars resolves year/era by formatting the date through `Intl.DateTimeFormat` and matching the result against a hardcoded era-name table — unlike calendars with a fixed year-offset from ISO (Buddhist, Taiwan, and Ethiopic Amete Alem, which the polyfill computes with pure arithmetic and never touches `Intl` for). CLDR's era-name output for these two calendars changed between ICU versions: under ICU ≥ 78 (the version Node 22 and 24 both bundle — this is an ICU-version boundary, not a Node-major one), every read _or_ write of Temporal's `"ethiopic"`/`"coptic"` calendar ids throws a `RangeError` (`Era am (ISO year …) was not matched by any era`) — confirmed directly, not a hypothetical. `"ethiopic-amete-alem"` (Temporal's `"ethioaa"` id) is unaffected, since it has no era at all and is resolved with pure arithmetic. GMT routes around the bug rather than inheriting it: month/day are identical across all three calendars (they share one annual cycle), so `convertDateToCalendar` reads/writes them via the safe `"ethioaa"` calendar and computes each calendar's own displayed year (+ era, for `"ethiopic"`) with GMT-owned arithmetic — ported from the same `EthiopicHelper`/`CopticHelper` epoch constants `@js-temporal/polyfill` itself uses internally, just evaluated in GMT's code instead of through the ICU-dependent path. See `internal/ethiopicFamilyCalendar.ts` for the implementation.
|
|
501
|
+
|
|
502
|
+
#### Calendar-aware interval and duration arithmetic
|
|
503
|
+
|
|
504
|
+
`convertDateToCalendar`'s output feeds directly back into `addDate`/`subtractDate`/`diffDate`/`diffDateAsDuration` and every `Date`-suffixed `plain/interval/*` function (`intervalContainsDate`, `intervalCountDate`, `splitIntervalByUnitDate`, and the rest) — calendar-unit arithmetic ("add 1 month") resolves in the value's own calendar rather than being rejected or silently treated as Gregorian:
|
|
505
|
+
|
|
506
|
+
```typescript
|
|
507
|
+
addDate("5784-06-15[u-ca=hebrew]", { months: 1 });
|
|
508
|
+
// "5784-07-15[u-ca=hebrew]" — Adar I (a leap-only 30-day month) -> Adar
|
|
509
|
+
|
|
510
|
+
intervalCountDate(
|
|
511
|
+
"5784-01-01[u-ca=hebrew]",
|
|
512
|
+
"5785-01-01[u-ca=hebrew]",
|
|
513
|
+
"month",
|
|
514
|
+
);
|
|
515
|
+
// 13 — a Hebrew leap year crosses 13 month boundaries, not 12 (ISO's answer for the same span)
|
|
516
|
+
|
|
517
|
+
diffDate("5784-06-15[u-ca=hebrew]", "5784-07-15[u-ca=hebrew]", "months");
|
|
518
|
+
// 1 — measured in the shared calendar when both endpoints carry the same tag
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
`utc/` and `unix/` reject a `[u-ca=...]` calendar annotation outright, and `duration/`'s `relativeTo` option accepts GMT's calendar-annotated string (not Temporal's own differently-shaped `[u-ca=...]` convention) when a calendar-aware anchor is needed:
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
durationAs("P1Y", "days", { relativeTo: "5784-06-15[u-ca=hebrew]" });
|
|
525
|
+
// 385 — a Hebrew leap year, not the 366 a Gregorian P1Y would total
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
`zoned/` has its own calendar-annotated grammar as of E7 (issue #152) — see "Calendar-aware zoned datetimes" below.
|
|
529
|
+
|
|
530
|
+
Interval functions that only compare or diff absolute instants (`intervalContainsDate`, `intervalsOverlapDate`, `intervalAbutsDate`, `intervalEngulfsDate`, `isValidDateInterval`, `intervalOverlappingDaysDate`) accept endpoints tagged with _different_ calendars, since ordering and day-counting don't depend on which calendar a date is expressed in. Functions that return a date _value_ (`intervalUnionDate`, `intervalIntersectionDate`, `intervalDifferenceDate`, `intervalXorDate`, `intervalXorAllDate`, `mergeIntervalsDate`, `intervalDivideEquallyDate`, `intervalSplitAtDate`) require every argument to share one calendar and return their sentinel (`null`/`[]`) on a mismatch, since there's no principled way to pick which calendar the output should be expressed in. See `context/roadmap/issues/E.md`'s "E5 outcome" section for the full per-function audit, including the negatives ("no change needed, verified why") this scope boundary implies — `*DateTime`/`*Time` variants, `unix/`, and `utc/` were all confirmed unaffected rather than assumed to be.
|
|
531
|
+
|
|
532
|
+
#### Calendar-aware zoned datetimes
|
|
533
|
+
|
|
534
|
+
A calendar-annotated `ZonedDateTime` string adds a time, a UTC offset and an IANA zone to the
|
|
535
|
+
plain grammar above:
|
|
536
|
+
|
|
537
|
+
```
|
|
538
|
+
<calendar-native-date>T<time><offset>[u-ca=<id>[;era=<era>]][<timeZone>]
|
|
539
|
+
|
|
540
|
+
5784-06-15T14:30:00-05:00[u-ca=hebrew][America/New_York]
|
|
541
|
+
0031-04-30T12:00:00+09:00[u-ca=japanese;era=heisei][Asia/Tokyo]
|
|
542
|
+
7517-12-30T00:30:00-04:00[u-ca=ethiopic-amete-alem][America/Santiago]
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
`convertZonedToCalendar` produces it, and `isValidCalendarZonedDateTime` validates it:
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
convertZonedToCalendar("2024-10-03T14:30:45-04:00[America/New_York]", "hebrew");
|
|
549
|
+
// "5785-01-01T14:30:45-04:00[u-ca=hebrew][America/New_York]"
|
|
550
|
+
|
|
551
|
+
addZoned("5784-06-15T14:30:00-05:00[u-ca=hebrew][America/New_York]", {
|
|
552
|
+
months: 1,
|
|
553
|
+
});
|
|
554
|
+
// "5784-07-15T14:30:00-04:00[u-ca=hebrew][America/New_York]"
|
|
555
|
+
// Adar I -> Adar AND EST -> EDT, resolved in one call. No ordering of a plain/ calendar
|
|
556
|
+
// operation and a zoned/ conversion produces this: do the calendar step first and DST is
|
|
557
|
+
// applied to an already-resolved wall time; do the zoned step first and there is no calendar
|
|
558
|
+
// left to step in.
|
|
559
|
+
|
|
560
|
+
addZoned("0031-04-30T12:00:00+09:00[u-ca=japanese;era=heisei][Asia/Tokyo]", {
|
|
561
|
+
days: 1,
|
|
562
|
+
});
|
|
563
|
+
// "0001-05-01T12:00:00+09:00[u-ca=japanese;era=reiwa][Asia/Tokyo]" — era re-derived, never copied
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
> **The `[u-ca=...]` segment comes BEFORE `[timeZone]` — the reverse of RFC 9557.** This is
|
|
567
|
+
> deliberate. GMT's digits are calendar-native (Hebrew year 5784, not ISO year 5784), so the
|
|
568
|
+
> string is never valid RFC 9557 to begin with, and the `;era=` suffix is not valid RFC 9557 at
|
|
569
|
+
> any ordering. Writing it in RFC order is actively dangerous:
|
|
570
|
+
> `Temporal.ZonedDateTime.from("5784-01-01T14:30:00-05:00[America/New_York][u-ca=hebrew]")`
|
|
571
|
+
> _succeeds_, silently reading 5784 as an ISO year — a ~3760-year misparse with no error. GMT's
|
|
572
|
+
> ordering makes that shape uniformly rejected instead.
|
|
573
|
+
|
|
574
|
+
Scope: `addZoned`, `subtractZoned`, `diffZoned`, `diffZonedAsDuration`, `convertZonedToCalendar`,
|
|
575
|
+
and the `zoned/interval/*` family. Everything else in `zoned/` still rejects the annotation —
|
|
576
|
+
`isValidZonedDateTime` is unchanged, so a function that has not opted in fails closed rather than
|
|
577
|
+
silently answering in the wrong calendar. `addZonedBusinessDays`/`subtractZonedBusinessDays` stay
|
|
578
|
+
out by design: day-of-week is ISO-fixed in every supported calendar, so a tag would change nothing
|
|
579
|
+
while implying it might.
|
|
580
|
+
|
|
581
|
+
Mixed-calendar endpoints follow the same split as `plain/`: ordering functions
|
|
582
|
+
(`intervalContainsZoned`, `intervalsOverlapZoned`, `intervalAbutsZoned`, `intervalEngulfsZoned`,
|
|
583
|
+
`intervalOverlappingDaysZoned`, `isValidCalendarZonedInterval`) accept them; the eight
|
|
584
|
+
value-returning set operations require one shared calendar and return their sentinel on a
|
|
585
|
+
mismatch. Measurement functions (`diffZoned`, `diffZonedAsDuration`, `intervalCountZoned`,
|
|
586
|
+
`intervalLengthZoned`, `splitIntervalByUnitZoned`) measure in the endpoints' shared calendar when
|
|
587
|
+
both tags match and fall back to Gregorian otherwise — mandatory here rather than merely
|
|
588
|
+
convenient, because `Temporal.ZonedDateTime.prototype.until` throws across mismatched calendars
|
|
589
|
+
for _every_ unit, including pure time units like hours.
|
|
590
|
+
|
|
591
|
+
### Durations
|
|
592
|
+
|
|
593
|
+
```typescript
|
|
594
|
+
import {
|
|
595
|
+
absDuration,
|
|
596
|
+
addDuration,
|
|
597
|
+
compareDurations,
|
|
598
|
+
diffDateAsDuration,
|
|
599
|
+
durationAs,
|
|
600
|
+
formatDuration,
|
|
601
|
+
getDurationSign,
|
|
602
|
+
getDurationUnit,
|
|
603
|
+
isValidDuration,
|
|
604
|
+
negateDuration,
|
|
605
|
+
normalizeDuration,
|
|
606
|
+
parseDuration,
|
|
607
|
+
subtractDuration,
|
|
608
|
+
} from "@northguild/gmt";
|
|
609
|
+
|
|
610
|
+
isValidDuration("P1DT2H30M");
|
|
611
|
+
// true
|
|
612
|
+
|
|
613
|
+
parseDuration("P1DT2H30M");
|
|
614
|
+
// "P1DT2H30M"
|
|
615
|
+
|
|
616
|
+
parseDuration("PT1.5S", { smallestUnit: "second", roundingMode: "trunc" });
|
|
617
|
+
// "PT1S"
|
|
618
|
+
|
|
619
|
+
parseDuration("not a duration");
|
|
620
|
+
// ""
|
|
621
|
+
|
|
622
|
+
addDuration("P1D", "PT2H");
|
|
623
|
+
// "P1DT2H"
|
|
624
|
+
|
|
625
|
+
subtractDuration("P1D", "PT2H");
|
|
626
|
+
// "PT22H"
|
|
627
|
+
|
|
628
|
+
normalizeDuration("PT90M", { largestUnit: "hour" });
|
|
629
|
+
// "PT1H30M"
|
|
630
|
+
|
|
631
|
+
normalizeDuration("P45D", { largestUnit: "month", relativeTo: "2024-01-01" });
|
|
632
|
+
// "P1M14D"
|
|
633
|
+
|
|
634
|
+
getDurationUnit("P1DT2H30M", "hours");
|
|
635
|
+
// 2 — the hours component as stored
|
|
636
|
+
|
|
637
|
+
durationAs("P1DT2H30M", "hours");
|
|
638
|
+
// 26.5 — the whole duration totalled into hours
|
|
639
|
+
|
|
640
|
+
durationAs("P1M", "days");
|
|
641
|
+
// null — a calendar unit needs a relativeTo anchor
|
|
642
|
+
|
|
643
|
+
durationAs("P1M", "days", { relativeTo: "2024-02-01" });
|
|
644
|
+
// 29
|
|
645
|
+
|
|
646
|
+
negateDuration("P1DT2H");
|
|
647
|
+
// "-P1DT2H"
|
|
648
|
+
|
|
649
|
+
absDuration("-P1DT2H");
|
|
650
|
+
// "P1DT2H"
|
|
651
|
+
|
|
652
|
+
getDurationSign("-P1DT2H");
|
|
653
|
+
// -1
|
|
654
|
+
|
|
655
|
+
compareDurations("PT60M", "PT1H");
|
|
656
|
+
// 0 — equal by length, not by spelling
|
|
657
|
+
|
|
658
|
+
compareDurations("P1M", "P30D", { relativeTo: "2024-01-01" });
|
|
659
|
+
// 1 — January is 31 days; relativeTo "2024-02-01" gives -1
|
|
660
|
+
|
|
661
|
+
formatDuration("P1DT2H30M", "en-US");
|
|
662
|
+
// "1 day, 2 hours, and 30 minutes"
|
|
663
|
+
|
|
664
|
+
formatDuration("P1DT2H30M", "en-US", { style: "short" });
|
|
665
|
+
// "1 day, 2 hr, & 30 min"
|
|
666
|
+
|
|
667
|
+
formatDuration("P1DT0H30M", "en-US");
|
|
668
|
+
// "1 day and 30 minutes"
|
|
669
|
+
|
|
670
|
+
diffDateAsDuration("2024-03-10", "2024-04-05", "days");
|
|
671
|
+
// "P26D" — bridges diffDate to an ISO duration string instead of a single-unit number
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
`getDurationUnit` reads a component as stored, while `durationAs` converts the whole duration — `getDurationUnit("PT90M", "hours")` is `0` but `durationAs("PT90M", "hours")` is `1.5`. `durationAs` and `compareDurations` return `null` when a calendar unit (year/month/week) is involved without a `relativeTo` anchor, the same documented constraint `normalizeDuration` carries; `negateDuration`, `absDuration`, `getDurationSign`, and `getDurationUnit` are sign/field reads and never need one.
|
|
675
|
+
|
|
676
|
+
`diffDateAsDuration`/`diffDateTimeAsDuration`/`diffZonedAsDuration`/`diffUnixAsDuration`/`diffUtcAsDuration` are sibling functions to `diffDate`/`diffDateTime`/`diffZoned`/`diffUnix`/`diffUtc`, returning an ISO 8601 duration string (sentinel `""`) instead of a single-unit number (sentinel `null`). They take a single `unit` (not an array) to set the duration's `largestUnit`.
|
|
677
|
+
|
|
678
|
+
### Intervals
|
|
679
|
+
|
|
680
|
+
Interval and range validators are available in two API shapes — **range validators** (matching `isValidDateRange`'s `{ value1, value2, options? }` object-param shape) and **interval validators** (`(start, end)` positional args, `start <= end` always):
|
|
681
|
+
|
|
682
|
+
```typescript
|
|
683
|
+
import {
|
|
684
|
+
isValidDateInterval,
|
|
685
|
+
isValidTimeInterval,
|
|
686
|
+
isValidDateTimeInterval,
|
|
687
|
+
isValidDateRange,
|
|
688
|
+
isValidTimeRange,
|
|
689
|
+
isValidDateTimeRange,
|
|
690
|
+
isValidUtcRange,
|
|
691
|
+
isValidUnixRange,
|
|
692
|
+
isValidZonedRange,
|
|
693
|
+
isValidUtcInterval,
|
|
694
|
+
isValidUnixInterval,
|
|
695
|
+
isValidZonedInterval,
|
|
696
|
+
} from "@northguild/gmt";
|
|
697
|
+
|
|
698
|
+
// Interval validators — positional args, start <= end
|
|
699
|
+
isValidDateInterval("2024-01-01", "2024-12-31");
|
|
700
|
+
// true
|
|
701
|
+
|
|
702
|
+
isValidTimeInterval("09:00:00", "17:00:00");
|
|
703
|
+
// true
|
|
704
|
+
|
|
705
|
+
isValidDateTimeInterval("2024-01-01T10:00:00", "2024-12-31T23:59:59");
|
|
706
|
+
// true
|
|
707
|
+
|
|
708
|
+
isValidZonedInterval(
|
|
709
|
+
"2024-01-01T10:00:00+00:00[UTC]",
|
|
710
|
+
"2024-12-31T23:59:59+00:00[UTC]",
|
|
711
|
+
);
|
|
712
|
+
// true
|
|
713
|
+
|
|
714
|
+
// Range validators — object params, with optional allowEqual
|
|
715
|
+
isValidDateRange({ value1: "2024-01-01", value2: "2024-12-31" });
|
|
716
|
+
// true
|
|
717
|
+
|
|
718
|
+
isValidTimeRange({ value1: "09:00:00", value2: "17:00:00" });
|
|
719
|
+
// true
|
|
720
|
+
|
|
721
|
+
isValidZonedRange({
|
|
722
|
+
value1: "2024-01-01T10:00:00+00:00[UTC]",
|
|
723
|
+
value2: "2024-12-31T23:59:59+00:00[UTC]",
|
|
724
|
+
});
|
|
725
|
+
// true
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Interval containment checks (`intervalContains*`) test whether a point or inner interval falls within an outer interval. Each supports two modes via an optional fourth argument:
|
|
729
|
+
|
|
730
|
+
- 3-arg: `intervalContains(start, end, point)` — true when `start <= point <= end`
|
|
731
|
+
- 4-arg: `intervalContains(start, end, innerStart, innerEnd)` — true when the inner interval is fully contained
|
|
732
|
+
|
|
733
|
+
```typescript
|
|
734
|
+
import {
|
|
735
|
+
intervalContainsDate,
|
|
736
|
+
intervalContainsTime,
|
|
737
|
+
intervalContainsDateTime,
|
|
738
|
+
intervalContainsUtc,
|
|
739
|
+
intervalContainsUnix,
|
|
740
|
+
intervalContainsZoned,
|
|
741
|
+
} from "@northguild/gmt";
|
|
742
|
+
|
|
743
|
+
// Point-in-interval (3-arg)
|
|
744
|
+
intervalContainsDate("2024-01-01", "2024-12-31", "2024-06-15");
|
|
745
|
+
// true
|
|
746
|
+
|
|
747
|
+
intervalContainsTime("09:00:00", "17:00:00", "12:00:00");
|
|
748
|
+
// true
|
|
749
|
+
|
|
750
|
+
intervalContainsUtc(
|
|
751
|
+
"2024-01-01T00:00:00Z",
|
|
752
|
+
"2024-12-31T23:59:59Z",
|
|
753
|
+
"2024-06-15T12:00:00Z",
|
|
754
|
+
);
|
|
755
|
+
// true
|
|
756
|
+
|
|
757
|
+
intervalContainsUnix(0, 1700000000, 170000000);
|
|
758
|
+
// true
|
|
759
|
+
|
|
760
|
+
intervalContainsZoned(
|
|
761
|
+
"2024-01-01T00:00:00+00:00[UTC]",
|
|
762
|
+
"2024-12-31T23:59:59+00:00[UTC]",
|
|
763
|
+
"2024-06-15T12:00:00+00:00[UTC]",
|
|
764
|
+
);
|
|
765
|
+
// true
|
|
766
|
+
|
|
767
|
+
// Interval-in-interval (4-arg)
|
|
768
|
+
intervalContainsDate("2024-01-01", "2024-12-31", "2024-03-01", "2024-09-01");
|
|
769
|
+
// true
|
|
770
|
+
|
|
771
|
+
intervalContainsTime("09:00:00", "17:00:00", "10:00:00", "16:00:00");
|
|
772
|
+
// true
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
All interval containment checks return `false` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
776
|
+
|
|
777
|
+
`intervalsOverlap*` checks whether two intervals share any time. Returns `true` when intervals overlap, `false` when they are disjoint or only adjacent (touching at a single instant with no shared time):
|
|
778
|
+
|
|
779
|
+
```typescript
|
|
780
|
+
import {
|
|
781
|
+
intervalsOverlapDate,
|
|
782
|
+
intervalsOverlapTime,
|
|
783
|
+
intervalsOverlapDateTime,
|
|
784
|
+
intervalsOverlapUtc,
|
|
785
|
+
intervalsOverlapUnix,
|
|
786
|
+
intervalsOverlapZoned,
|
|
787
|
+
} from "@northguild/gmt";
|
|
788
|
+
|
|
789
|
+
intervalsOverlapDate("2024-01-01", "2024-06-30", "2024-04-01", "2024-12-31");
|
|
790
|
+
// true
|
|
791
|
+
|
|
792
|
+
intervalsOverlapDate("2024-01-01", "2024-06-30", "2024-06-30", "2024-12-31");
|
|
793
|
+
// false (adjacent, no shared time)
|
|
794
|
+
|
|
795
|
+
intervalsOverlapUnix(0, 1700000000, 1000000, 2000000);
|
|
796
|
+
// true
|
|
797
|
+
|
|
798
|
+
intervalsOverlapUtc(
|
|
799
|
+
"2024-01-01T00:00:00Z",
|
|
800
|
+
"2024-06-30T23:59:59Z",
|
|
801
|
+
"2024-04-01T00:00:00Z",
|
|
802
|
+
"2024-12-31T23:59:59Z",
|
|
803
|
+
);
|
|
804
|
+
// true
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
All overlap checks return `false` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
808
|
+
|
|
809
|
+
`intervalIntersection*` returns the overlapping span of two intervals, or `null` when they do not overlap. Adjacent intervals (sharing one instant) count as overlapping and return a single-point span:
|
|
810
|
+
|
|
811
|
+
```typescript
|
|
812
|
+
import {
|
|
813
|
+
intervalIntersectionDate,
|
|
814
|
+
intervalIntersectionTime,
|
|
815
|
+
intervalIntersectionDateTime,
|
|
816
|
+
intervalIntersectionUtc,
|
|
817
|
+
intervalIntersectionUnix,
|
|
818
|
+
intervalIntersectionZoned,
|
|
819
|
+
} from "@northguild/gmt";
|
|
820
|
+
|
|
821
|
+
intervalIntersectionDate(
|
|
822
|
+
"2024-01-01",
|
|
823
|
+
"2024-06-30",
|
|
824
|
+
"2024-04-01",
|
|
825
|
+
"2024-12-31",
|
|
826
|
+
);
|
|
827
|
+
// { start: "2024-04-01", end: "2024-06-30" }
|
|
828
|
+
|
|
829
|
+
intervalIntersectionDate(
|
|
830
|
+
"2024-01-01",
|
|
831
|
+
"2024-06-30",
|
|
832
|
+
"2024-06-30",
|
|
833
|
+
"2024-12-31",
|
|
834
|
+
);
|
|
835
|
+
// { start: "2024-06-30", end: "2024-06-30" } (adjacent, shares one instant)
|
|
836
|
+
|
|
837
|
+
intervalIntersectionDate(
|
|
838
|
+
"2024-01-01",
|
|
839
|
+
"2024-06-30",
|
|
840
|
+
"2024-07-01",
|
|
841
|
+
"2024-12-31",
|
|
842
|
+
);
|
|
843
|
+
// null (disjoint)
|
|
844
|
+
|
|
845
|
+
intervalIntersectionUnix(0, 1700000000, 1000000, 2000000);
|
|
846
|
+
// { start: 1000000, end: 1700000000 }
|
|
847
|
+
|
|
848
|
+
intervalIntersectionUtc(
|
|
849
|
+
"2024-01-01T00:00:00Z",
|
|
850
|
+
"2024-06-30T23:59:59Z",
|
|
851
|
+
"2024-04-01T00:00:00Z",
|
|
852
|
+
"2024-12-31T23:59:59Z",
|
|
853
|
+
);
|
|
854
|
+
// { start: "2024-04-01T00:00:00Z", end: "2024-06-30T23:59:59Z" }
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
All intersection functions return `null` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
858
|
+
|
|
859
|
+
`intervalOverlappingDays*` returns how many distinct calendar dates two intervals share — the numeric counterpart to `intervalIntersection*`'s span. Counting is inclusive of both endpoints of the closed intersection `[max(aStart, bStart), min(aEnd, bEnd)]`, so `intervalOverlappingDaysDate("2024-01-01", "2024-01-01", "2024-01-01", "2024-01-01")` is `1`, not `0`. There is no `Time` variant — `PlainTime` has no calendar, so a day count is undefined for it:
|
|
860
|
+
|
|
861
|
+
```typescript
|
|
862
|
+
import {
|
|
863
|
+
intervalOverlappingDaysDate,
|
|
864
|
+
intervalOverlappingDaysDateTime,
|
|
865
|
+
intervalOverlappingDaysUtc,
|
|
866
|
+
intervalOverlappingDaysUnix,
|
|
867
|
+
intervalOverlappingDaysZoned,
|
|
868
|
+
} from "@northguild/gmt";
|
|
869
|
+
|
|
870
|
+
intervalOverlappingDaysDate(
|
|
871
|
+
"2024-01-01",
|
|
872
|
+
"2024-06-30",
|
|
873
|
+
"2024-04-01",
|
|
874
|
+
"2024-12-31",
|
|
875
|
+
);
|
|
876
|
+
// 91
|
|
877
|
+
|
|
878
|
+
intervalOverlappingDaysDate(
|
|
879
|
+
"2024-01-01",
|
|
880
|
+
"2024-06-30",
|
|
881
|
+
"2024-06-30",
|
|
882
|
+
"2024-12-31",
|
|
883
|
+
);
|
|
884
|
+
// 1 (adjacent, shares one date)
|
|
885
|
+
|
|
886
|
+
intervalOverlappingDaysDate(
|
|
887
|
+
"2024-01-01",
|
|
888
|
+
"2024-06-30",
|
|
889
|
+
"2024-07-01",
|
|
890
|
+
"2024-12-31",
|
|
891
|
+
);
|
|
892
|
+
// 0 (disjoint)
|
|
893
|
+
|
|
894
|
+
intervalOverlappingDaysUnix(0, 172800000, 86400000, 259200000, {
|
|
895
|
+
timeZone: "UTC",
|
|
896
|
+
});
|
|
897
|
+
// 2
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
Returns `0` when the intervals do not overlap (a well-defined answer, not invalid input) and `null` on invalid input, including an inverted interval (`start > end`). `intervalOverlappingDaysZoned` and `intervalOverlappingDaysUnix` count days in `aStart`'s time zone (`intervalOverlappingDaysUnix` defaults to the system time zone, overridable via `{ timeZone }`) — the same rule `intervalCountZoned`/`intervalCountUnix` use — so `intervalOverlappingDaysZoned` is **not commutative** when the two intervals carry different zones: swapping the arguments can change the answer.
|
|
901
|
+
|
|
902
|
+
This deliberately diverges from date-fns's `getOverlappingDaysInIntervals`, which rounds up elapsed 24-hour periods instead of counting calendar dates — its own doc example (`Jan 10–20` vs `Jan 17–21`) returns `3` there and `4` here. To reproduce date-fns's number, compose `intervalIntersection*` with `intervalCount*`:
|
|
903
|
+
|
|
904
|
+
```typescript
|
|
905
|
+
const span = intervalIntersectionDate(aStart, aEnd, bStart, bEnd);
|
|
906
|
+
span ? intervalCountDate(span.start, span.end, "day") : 0; // date-fns semantics
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
`intervalUnion*` returns the combined span of two overlapping or adjacent intervals, or `null` when they are disjoint with a gap. Adjacent intervals (sharing one instant) count as mergeable:
|
|
910
|
+
|
|
911
|
+
```typescript
|
|
912
|
+
import {
|
|
913
|
+
intervalUnionDate,
|
|
914
|
+
intervalUnionTime,
|
|
915
|
+
intervalUnionDateTime,
|
|
916
|
+
intervalUnionUtc,
|
|
917
|
+
intervalUnionUnix,
|
|
918
|
+
intervalUnionZoned,
|
|
919
|
+
} from "@northguild/gmt";
|
|
920
|
+
|
|
921
|
+
intervalUnionDate("2024-01-01", "2024-06-30", "2024-04-01", "2024-12-31");
|
|
922
|
+
// { start: "2024-01-01", end: "2024-12-31" }
|
|
923
|
+
|
|
924
|
+
intervalUnionDate("2024-01-01", "2024-06-30", "2024-06-30", "2024-12-31");
|
|
925
|
+
// { start: "2024-01-01", end: "2024-12-31" } (adjacent, merged)
|
|
926
|
+
|
|
927
|
+
intervalUnionDate("2024-01-01", "2024-06-30", "2024-07-01", "2024-12-31");
|
|
928
|
+
// null (disjoint with a gap)
|
|
929
|
+
|
|
930
|
+
intervalUnionUnix(0, 1700000000, 1000000, 2000000);
|
|
931
|
+
// { start: 0, end: 1700000000 }
|
|
932
|
+
|
|
933
|
+
intervalUnionUtc(
|
|
934
|
+
"2024-01-01T00:00:00Z",
|
|
935
|
+
"2024-06-30T23:59:59Z",
|
|
936
|
+
"2024-04-01T00:00:00Z",
|
|
937
|
+
"2024-12-31T23:59:59Z",
|
|
938
|
+
);
|
|
939
|
+
// { start: "2024-01-01T00:00:00Z", end: "2024-12-31T23:59:59Z" }
|
|
940
|
+
```
|
|
941
|
+
|
|
942
|
+
All union functions return `null` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
943
|
+
|
|
944
|
+
`intervalDifference*` returns the portion(s) of interval A not covered by interval B, as an array of `{ start, end }` records:
|
|
945
|
+
|
|
946
|
+
```typescript
|
|
947
|
+
import {
|
|
948
|
+
intervalDifferenceDate,
|
|
949
|
+
intervalDifferenceTime,
|
|
950
|
+
intervalDifferenceDateTime,
|
|
951
|
+
intervalDifferenceUtc,
|
|
952
|
+
intervalDifferenceUnix,
|
|
953
|
+
intervalDifferenceZoned,
|
|
954
|
+
} from "@northguild/gmt";
|
|
955
|
+
|
|
956
|
+
intervalDifferenceDate("2024-01-01", "2024-12-31", "2024-06-01", "2024-07-01");
|
|
957
|
+
// [{ start: "2024-01-01", end: "2024-05-31" }, { start: "2024-07-02", end: "2024-12-31" }]
|
|
958
|
+
|
|
959
|
+
intervalDifferenceDate("2024-01-01", "2024-12-31", "2024-01-01", "2024-12-31");
|
|
960
|
+
// [] (B fully covers A)
|
|
961
|
+
|
|
962
|
+
intervalDifferenceUnix(0, 1700000000, 1000000, 2000000);
|
|
963
|
+
// [{ start: 0, end: 999999 }, { start: 2000001, end: 1700000000 }]
|
|
964
|
+
|
|
965
|
+
intervalDifferenceUtc(
|
|
966
|
+
"2024-01-01T00:00:00Z",
|
|
967
|
+
"2024-12-31T23:59:59Z",
|
|
968
|
+
"2024-06-01T00:00:00Z",
|
|
969
|
+
"2024-07-01T00:00:00Z",
|
|
970
|
+
);
|
|
971
|
+
// [{ start: "2024-01-01T00:00:00Z", end: "2024-05-31T23:59:59Z" }, { start: "2024-07-02T00:00:00Z", end: "2024-12-31T23:59:59Z" }]
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
All difference functions return `[]` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
975
|
+
|
|
976
|
+
`intervalXor*` returns the symmetric difference of two intervals — the portions covered by exactly one of them, not both — as an array of `{ start, end }` records:
|
|
977
|
+
|
|
978
|
+
```typescript
|
|
979
|
+
import {
|
|
980
|
+
intervalXorDate,
|
|
981
|
+
intervalXorTime,
|
|
982
|
+
intervalXorDateTime,
|
|
983
|
+
intervalXorUtc,
|
|
984
|
+
intervalXorUnix,
|
|
985
|
+
intervalXorZoned,
|
|
986
|
+
} from "@northguild/gmt";
|
|
987
|
+
|
|
988
|
+
intervalXorDate("2024-01-01", "2024-06-30", "2024-04-01", "2024-12-31");
|
|
989
|
+
// [{ start: "2024-01-01", end: "2024-03-31" }, { start: "2024-07-01", end: "2024-12-31" }]
|
|
990
|
+
|
|
991
|
+
intervalXorDate("2024-01-01", "2024-06-30", "2024-06-30", "2024-12-31");
|
|
992
|
+
// [{ start: "2024-01-01", end: "2024-06-29" }, { start: "2024-07-01", end: "2024-12-31" }] (adjacent)
|
|
993
|
+
|
|
994
|
+
intervalXorUnix(0, 1700000000, 1000000, 2000000);
|
|
995
|
+
// [{ start: 0, end: 999999 }, { start: 2000001, end: 1700000000 }]
|
|
996
|
+
|
|
997
|
+
intervalXorUtc(
|
|
998
|
+
"2024-01-01T00:00:00Z",
|
|
999
|
+
"2024-06-30T23:59:59Z",
|
|
1000
|
+
"2024-04-01T00:00:00Z",
|
|
1001
|
+
"2024-12-31T23:59:59Z",
|
|
1002
|
+
);
|
|
1003
|
+
// [{ start: "2024-01-01T00:00:00Z", end: "2024-03-31T23:59:59Z" }, { start: "2024-07-01T00:00:00Z", end: "2024-12-31T23:59:59Z" }]
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
All xor functions return `[]` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
1007
|
+
|
|
1008
|
+
`intervalAbuts*` checks whether two intervals are exactly adjacent — one's end equals the other's start with zero gap and zero overlap:
|
|
1009
|
+
|
|
1010
|
+
```typescript
|
|
1011
|
+
import {
|
|
1012
|
+
intervalAbutsDate,
|
|
1013
|
+
intervalAbutsTime,
|
|
1014
|
+
intervalAbutsDateTime,
|
|
1015
|
+
intervalAbutsUtc,
|
|
1016
|
+
intervalAbutsUnix,
|
|
1017
|
+
intervalAbutsZoned,
|
|
1018
|
+
} from "@northguild/gmt";
|
|
1019
|
+
|
|
1020
|
+
intervalAbutsDate("2024-01-01", "2024-06-30", "2024-06-30", "2024-12-31");
|
|
1021
|
+
// true
|
|
1022
|
+
|
|
1023
|
+
intervalAbutsDate("2024-01-01", "2024-06-29", "2024-06-30", "2024-12-31");
|
|
1024
|
+
// false (one-day gap)
|
|
1025
|
+
|
|
1026
|
+
intervalAbutsDate("2024-01-01", "2024-06-30", "2024-04-01", "2024-12-31");
|
|
1027
|
+
// false (overlap)
|
|
1028
|
+
|
|
1029
|
+
intervalAbutsUnix(0, 1000000, 1000000, 2000000);
|
|
1030
|
+
// true
|
|
1031
|
+
|
|
1032
|
+
intervalAbutsUtc(
|
|
1033
|
+
"2024-01-01T00:00:00Z",
|
|
1034
|
+
"2024-06-30T23:59:59Z",
|
|
1035
|
+
"2024-06-30T23:59:59Z",
|
|
1036
|
+
"2024-12-31T23:59:59Z",
|
|
1037
|
+
);
|
|
1038
|
+
// true
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
All abuts checks return `false` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
1042
|
+
|
|
1043
|
+
`intervalEngulfs*` checks whether interval B is fully contained within interval A — every instant of B falls within A. Equivalent to the 4-argument `intervalContains*` mode:
|
|
1044
|
+
|
|
1045
|
+
```typescript
|
|
1046
|
+
import {
|
|
1047
|
+
intervalEngulfsDate,
|
|
1048
|
+
intervalEngulfsTime,
|
|
1049
|
+
intervalEngulfsDateTime,
|
|
1050
|
+
intervalEngulfsUtc,
|
|
1051
|
+
intervalEngulfsUnix,
|
|
1052
|
+
intervalEngulfsZoned,
|
|
1053
|
+
} from "@northguild/gmt";
|
|
1054
|
+
|
|
1055
|
+
intervalEngulfsDate("2024-01-01", "2024-12-31", "2024-06-01", "2024-07-01");
|
|
1056
|
+
// true
|
|
1057
|
+
|
|
1058
|
+
intervalEngulfsDate("2024-01-01", "2024-12-31", "2024-01-01", "2024-12-31");
|
|
1059
|
+
// true (equal intervals)
|
|
1060
|
+
|
|
1061
|
+
intervalEngulfsDate("2024-06-01", "2024-07-01", "2024-01-01", "2024-12-31");
|
|
1062
|
+
// false
|
|
1063
|
+
|
|
1064
|
+
intervalEngulfsUnix(0, 1700000000, 1000000, 2000000);
|
|
1065
|
+
// true
|
|
1066
|
+
|
|
1067
|
+
intervalEngulfsUtc(
|
|
1068
|
+
"2024-01-01T00:00:00Z",
|
|
1069
|
+
"2024-12-31T23:59:59Z",
|
|
1070
|
+
"2024-06-01T00:00:00Z",
|
|
1071
|
+
"2024-07-01T00:00:00Z",
|
|
1072
|
+
);
|
|
1073
|
+
// true
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
All engulfs checks return `false` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-finite values for Unix).
|
|
1077
|
+
|
|
1078
|
+
`splitIntervalByUnit*` splits an interval into sub-intervals of `amount × unit`, returning an array of `{ start, end }` records. The final sub-interval is trimmed so its `end` never exceeds the original `end`:
|
|
1079
|
+
|
|
1080
|
+
```typescript
|
|
1081
|
+
import {
|
|
1082
|
+
splitIntervalByUnitDate,
|
|
1083
|
+
splitIntervalByUnitTime,
|
|
1084
|
+
splitIntervalByUnitDateTime,
|
|
1085
|
+
splitIntervalByUnitUtc,
|
|
1086
|
+
splitIntervalByUnitUnix,
|
|
1087
|
+
splitIntervalByUnitZoned,
|
|
1088
|
+
} from "@northguild/gmt";
|
|
1089
|
+
|
|
1090
|
+
splitIntervalByUnitDate("2024-01-01", "2024-01-10", "day", 2);
|
|
1091
|
+
// [{ start: "2024-01-01", end: "2024-01-03" }, { start: "2024-01-03", end: "2024-01-05" }, { start: "2024-01-05", end: "2024-01-07" }, { start: "2024-01-07", end: "2024-01-09" }, { start: "2024-01-09", end: "2024-01-10" }]
|
|
1092
|
+
|
|
1093
|
+
splitIntervalByUnitUtc(
|
|
1094
|
+
"2024-01-01T00:00:00Z",
|
|
1095
|
+
"2024-01-02T00:00:00Z",
|
|
1096
|
+
"hour",
|
|
1097
|
+
6,
|
|
1098
|
+
);
|
|
1099
|
+
// [{ start: "2024-01-01T00:00:00Z", end: "2024-01-01T06:00:00Z" }, { start: "2024-01-01T06:00:00Z", end: "2024-01-01T12:00:00Z" }, { start: "2024-01-01T12:00:00Z", end: "2024-01-01T18:00:00Z" }, { start: "2024-01-01T18:00:00Z", end: "2024-01-02T00:00:00Z" }]
|
|
1100
|
+
|
|
1101
|
+
splitIntervalByUnitUnix(0, 86400000, "hour", 6);
|
|
1102
|
+
// [{ start: 0, end: 21600000 }, { start: 21600000, end: 43200000 }, { start: 43200000, end: 64800000 }, { start: 64800000, end: 86400000 }]
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
All split functions return `[]` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, non-positive amount, unsupported unit, or a unit that has no effect on the target type).
|
|
1106
|
+
|
|
1107
|
+
`intervalCount*` returns how many calendar-unit boundaries an interval crosses — the number of units the half-open interval `[start, end)` touches. This is distinct from `diff*`, which measures exact elapsed duration: an interval from 23:59 to 00:01 is two minutes long but touches two days:
|
|
1108
|
+
|
|
1109
|
+
```typescript
|
|
1110
|
+
import {
|
|
1111
|
+
intervalCountDate,
|
|
1112
|
+
intervalCountTime,
|
|
1113
|
+
intervalCountDateTime,
|
|
1114
|
+
intervalCountUtc,
|
|
1115
|
+
intervalCountUnix,
|
|
1116
|
+
intervalCountZoned,
|
|
1117
|
+
} from "@northguild/gmt";
|
|
1118
|
+
|
|
1119
|
+
intervalCountDateTime("2024-01-01T23:59:00", "2024-01-02T00:01:00", "day");
|
|
1120
|
+
// 2 (two minutes long, but two days touched)
|
|
1121
|
+
|
|
1122
|
+
intervalCountDate("2024-01-01", "2024-01-03", "day");
|
|
1123
|
+
// 2 (the end boundary is excluded)
|
|
1124
|
+
|
|
1125
|
+
intervalCountDate("2024-01-15", "2024-03-10", "month");
|
|
1126
|
+
// 3
|
|
1127
|
+
|
|
1128
|
+
intervalCountTime("12:30:00", "13:00:00", "hour");
|
|
1129
|
+
// 1
|
|
1130
|
+
|
|
1131
|
+
intervalCountZoned(
|
|
1132
|
+
"2024-03-10T00:00:00-05:00[America/New_York]",
|
|
1133
|
+
"2024-03-11T00:00:00-04:00[America/New_York]",
|
|
1134
|
+
"hour",
|
|
1135
|
+
);
|
|
1136
|
+
// 23 (the spring-forward local day is 23 hours long)
|
|
1137
|
+
|
|
1138
|
+
intervalCountUnix(0, 86400000, "hour");
|
|
1139
|
+
// 24
|
|
1140
|
+
```
|
|
1141
|
+
|
|
1142
|
+
Zero-length intervals count `1` when they sit mid-unit and `0` when they sit exactly on a unit boundary — `intervalCountDate("2024-01-15", "2024-01-15", "month")` is `1`, while `intervalCountDate("2024-01-01", "2024-01-01", "month")` is `0`. Weeks start on Monday (ISO 8601), singular and plural units are interchangeable (`"day"` and `"days"`), and `intervalCountUnix` uses the system timeZone for calendar boundaries (consistent with `addUnix`). All count functions return `null` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, unsupported unit, or a unit that has no effect on the target type).
|
|
1143
|
+
|
|
1144
|
+
`intervalLength*` is `intervalCount*`'s exact-duration counterpart — it answers "how long is this interval" as a real, possibly fractional number, rather than "how many boundaries does it touch":
|
|
1145
|
+
|
|
1146
|
+
```typescript
|
|
1147
|
+
import {
|
|
1148
|
+
intervalLengthDate,
|
|
1149
|
+
intervalLengthTime,
|
|
1150
|
+
intervalLengthDateTime,
|
|
1151
|
+
intervalLengthUtc,
|
|
1152
|
+
intervalLengthUnix,
|
|
1153
|
+
intervalLengthZoned,
|
|
1154
|
+
} from "@northguild/gmt";
|
|
1155
|
+
|
|
1156
|
+
intervalLengthDateTime("2024-01-01T23:59:00", "2024-01-02T00:01:00", "day");
|
|
1157
|
+
// 0.001388888888888889 (the same interval intervalCount* reports as 2 day boundaries)
|
|
1158
|
+
|
|
1159
|
+
intervalLengthDate("2024-01-01", "2024-01-16", "month");
|
|
1160
|
+
// 0.4838709677419355 (15 of January's 31 days)
|
|
1161
|
+
|
|
1162
|
+
intervalLengthZoned(
|
|
1163
|
+
"2024-03-10T00:00:00-05:00[America/New_York]",
|
|
1164
|
+
"2024-03-11T00:00:00-04:00[America/New_York]",
|
|
1165
|
+
"hour",
|
|
1166
|
+
);
|
|
1167
|
+
// 23 (spring-forward local day is 23 real hours)
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1170
|
+
`intervalLength*` uses `Temporal.Duration.prototype.total`, so calendar units (month, year) resolve against the interval's own `start` rather than truncating, and zoned/unix/utc variants are DST-aware the same way `intervalCount*` is. Returns `0` for a zero-length interval, and `null` on invalid input (wrong type, malformed strings, leap seconds, inverted intervals, unsupported unit).
|
|
1171
|
+
|
|
1172
|
+
`intervalDivideEqually*` splits an interval into `n` equal-length sub-intervals, and `intervalSplitAt*` splits an interval at arbitrary points instead of by count:
|
|
1173
|
+
|
|
1174
|
+
```typescript
|
|
1175
|
+
import {
|
|
1176
|
+
intervalDivideEquallyDate,
|
|
1177
|
+
intervalSplitAtDate,
|
|
1178
|
+
} from "@northguild/gmt";
|
|
1179
|
+
|
|
1180
|
+
intervalDivideEquallyDate("2024-01-01", "2024-01-05", 4);
|
|
1181
|
+
// [{ start: "2024-01-01", end: "2024-01-02" }, { start: "2024-01-02", end: "2024-01-03" }, { start: "2024-01-03", end: "2024-01-04" }, { start: "2024-01-04", end: "2024-01-05" }]
|
|
1182
|
+
|
|
1183
|
+
intervalSplitAtDate("2024-01-01", "2024-01-10", ["2024-01-07", "2024-01-03"]);
|
|
1184
|
+
// [{ start: "2024-01-01", end: "2024-01-03" }, { start: "2024-01-03", end: "2024-01-07" }, { start: "2024-01-07", end: "2024-01-10" }]
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
`n` must be a positive integer (`[]` otherwise); `n === 1` returns the original interval unchanged, and a zero-length interval returns `n` identical zero-length sub-intervals. Non-fractional types (`PlainDate`) round internal boundaries to the nearest whole unit; every other variant is exact, computed from total elapsed nanoseconds (`intervalDivideEquallyZoned` splits DST-crossing intervals by real elapsed time, not local clock time). `intervalSplitAt*` sorts its `points` internally — they need not be pre-sorted — and drops points outside `[start, end]` or exactly on a boundary, since those cannot introduce a new sub-interval; an empty or all-dropped `points` array returns `[{ start, end }]` unsplit.
|
|
1188
|
+
|
|
1189
|
+
`mergeIntervals*` and `intervalXorAll*` are the list-form generalizations of `intervalUnion*` and `intervalXor*`, which are pairwise only — each takes a single array of `{ start, end }` records instead of two flat intervals:
|
|
1190
|
+
|
|
1191
|
+
```typescript
|
|
1192
|
+
import { mergeIntervalsDate, intervalXorAllDate } from "@northguild/gmt";
|
|
1193
|
+
|
|
1194
|
+
mergeIntervalsDate([
|
|
1195
|
+
{ start: "2024-01-01", end: "2024-01-10" },
|
|
1196
|
+
{ start: "2024-01-05", end: "2024-01-15" },
|
|
1197
|
+
]);
|
|
1198
|
+
// [{ start: "2024-01-01", end: "2024-01-15" }]
|
|
1199
|
+
|
|
1200
|
+
intervalXorAllDate([
|
|
1201
|
+
{ start: "2024-01-01", end: "2024-01-10" },
|
|
1202
|
+
{ start: "2024-01-05", end: "2024-01-15" },
|
|
1203
|
+
{ start: "2024-01-08", end: "2024-01-20" },
|
|
1204
|
+
]);
|
|
1205
|
+
// [{ start: "2024-01-01", end: "2024-01-04" }, { start: "2024-01-08", end: "2024-01-10" }, { start: "2024-01-16", end: "2024-01-20" }]
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
`mergeIntervals*` collapses overlapping or adjacent intervals (shared endpoint) into the minimum non-overlapping set. `intervalXorAll*` returns the set covered by an odd number of the input intervals — for exactly two intervals the result is identical to the pairwise `intervalXor*`, and two identical intervals cancel out to `[]`. All four return `[]` for an empty list or on invalid input.
|
|
1209
|
+
|
|
1210
|
+
`intervalFromDuration*` constructs an interval from a single point plus an ISO 8601 duration, anchored at either end — Luxon's `Interval.after`/`Interval.before` as one function with an `anchor` param instead of two:
|
|
1211
|
+
|
|
1212
|
+
```typescript
|
|
1213
|
+
import {
|
|
1214
|
+
intervalFromDurationDate,
|
|
1215
|
+
intervalFromDurationTime,
|
|
1216
|
+
intervalFromDurationDateTime,
|
|
1217
|
+
intervalFromDurationUtc,
|
|
1218
|
+
intervalFromDurationUnix,
|
|
1219
|
+
intervalFromDurationZoned,
|
|
1220
|
+
} from "@northguild/gmt";
|
|
1221
|
+
|
|
1222
|
+
intervalFromDurationDate("2024-01-01", "P1M", "start");
|
|
1223
|
+
// { start: "2024-01-01", end: "2024-02-01" }
|
|
1224
|
+
|
|
1225
|
+
intervalFromDurationDate("2024-02-01", "P1M", "end");
|
|
1226
|
+
// { start: "2024-01-01", end: "2024-02-01" }
|
|
1227
|
+
|
|
1228
|
+
intervalFromDurationZoned(
|
|
1229
|
+
"2024-03-09T02:30:00-05:00[America/New_York]",
|
|
1230
|
+
"P1D",
|
|
1231
|
+
"start",
|
|
1232
|
+
);
|
|
1233
|
+
// { start: "2024-03-09T02:30:00-05:00[America/New_York]", end: "2024-03-10T03:30:00-04:00[America/New_York]" } (spring-forward day is 23 hours long)
|
|
1234
|
+
|
|
1235
|
+
intervalFromDurationTime("12:00:00", "P1D", "start");
|
|
1236
|
+
// null (PlainTime has no calendar — a date-unit duration needs a relativeTo it can't supply)
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
Calendar units (years/months/weeks) resolve against `value` itself, so no separate `relativeTo` is needed — except for `intervalFromDurationTime`, which returns `null` for a `duration` with a nonzero years/months/weeks/days component, since `PlainTime` has no calendar to resolve it against. `intervalFromDurationZoned` accepts the same `disambiguation`/`offset`/`overflow` options as `addZoned`; `intervalFromDurationUnix` accepts `addUnix`'s `epochUnit`/`timeZone`/`overflow` options. A negative `duration` that inverts the computed span, or an `overflow: "reject"` result, returns `null` — same sentinel as any other invalid input.
|
|
1240
|
+
|
|
1241
|
+
All validators return `false` on invalid input (wrong type, malformed strings, leap seconds, mixed kinds for plain interval validators, non-finite values for Unix).
|
|
1242
|
+
|
|
1243
|
+
### Zoned operations
|
|
1244
|
+
|
|
1245
|
+
```typescript
|
|
1246
|
+
import { addZoned, formatZonedDateTime } from "@northguild/gmt";
|
|
1247
|
+
|
|
1248
|
+
addZoned("2026-03-07T23:00:00-05:00[America/New_York]", 2, "hour");
|
|
1249
|
+
// "2026-03-08T01:00:00-05:00[America/New_York]"
|
|
1250
|
+
|
|
1251
|
+
formatZonedDateTime("2024-03-17T14:30:45+00:00[UTC]", "en-US", {
|
|
1252
|
+
dateStyle: "full",
|
|
1253
|
+
timeStyle: "short",
|
|
1254
|
+
});
|
|
1255
|
+
// locale-dependent non-empty formatted string
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
Twice a year, DST creates local times that don't exist (spring-forward gap) or happen twice (fall-back overlap). Functions that attach a timezone to a plain/local value accept an optional `disambiguation` (`"compatible"` (default) | `"earlier"` | `"later"` | `"reject"`) to control how that's resolved instead of silently guessing:
|
|
1259
|
+
|
|
1260
|
+
```typescript
|
|
1261
|
+
import { convertPlainDateTimeToZoned } from "@northguild/gmt";
|
|
1262
|
+
|
|
1263
|
+
// 2024-03-10T02:30:00 doesn't exist in America/New_York (clocks jump 2am -> 3am).
|
|
1264
|
+
convertPlainDateTimeToZoned("2024-03-10T02:30:00", "America/New_York", {
|
|
1265
|
+
disambiguation: "reject",
|
|
1266
|
+
});
|
|
1267
|
+
// "" — no such local time exists
|
|
1268
|
+
```
|
|
1269
|
+
|
|
1270
|
+
The `startOfZoned`/`endOfZoned`/`startOfQuarterForZoned`/`endOfQuarterForZoned`/`mapZonedHoursInDay` family (and their `unix/` counterparts) also accept `disambiguation`, plus an `offset` option (`"prefer"` | `"use"` | `"ignore"` (default) | `"reject"`) that controls whether the source's existing UTC offset is kept when computing the new boundary. **`offset` must stay at its default (`"ignore"`) for `disambiguation` to take effect** — Temporal's own default (`"prefer"`) keeps the source offset whenever still valid, which silently makes `disambiguation` a no-op:
|
|
1271
|
+
|
|
1272
|
+
```typescript
|
|
1273
|
+
import { startOfZoned } from "@northguild/gmt";
|
|
1274
|
+
|
|
1275
|
+
// 2024-11-03T01:45:00-05:00 is the SECOND, repeated 1am of the fall-back overlap in America/New_York.
|
|
1276
|
+
const source = "2024-11-03T01:45:00-05:00[America/New_York]";
|
|
1277
|
+
|
|
1278
|
+
startOfZoned(source, "hour", { disambiguation: "reject" });
|
|
1279
|
+
// "" — offset defaults to "ignore", so disambiguation actually fires and "reject" throws
|
|
1280
|
+
|
|
1281
|
+
startOfZoned(source, "hour", { disambiguation: "reject", offset: "prefer" });
|
|
1282
|
+
// "2024-11-03T01:00:00-05:00[America/New_York]" — offset:"prefer" keeps the source's
|
|
1283
|
+
// still-valid -05:00 offset, so disambiguation is never consulted and "reject" never fires
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
`convertPlainDateTimeToZoned` and `addZoned`/`subtractZoned` also accept `offset` for API consistency, but it's permanently inert on both — their construction path never has a stored offset for it to act on.
|
|
1287
|
+
|
|
1288
|
+
`hasDaylightSaving` reports whether an IANA timezone observes daylight saving time at all:
|
|
1289
|
+
|
|
1290
|
+
```typescript
|
|
1291
|
+
import { hasDaylightSaving } from "@northguild/gmt";
|
|
1292
|
+
|
|
1293
|
+
hasDaylightSaving("America/New_York");
|
|
1294
|
+
// true
|
|
1295
|
+
|
|
1296
|
+
hasDaylightSaving("Asia/Tokyo");
|
|
1297
|
+
// false
|
|
1298
|
+
|
|
1299
|
+
hasDaylightSaving("Invalid/Zone");
|
|
1300
|
+
// false
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
`getDstTransitions` enumerates the exact transition instants for a timezone in a given year:
|
|
1304
|
+
|
|
1305
|
+
```typescript
|
|
1306
|
+
import { getDstTransitions } from "@northguild/gmt/zoned";
|
|
1307
|
+
|
|
1308
|
+
getDstTransitions("America/New_York", 2024);
|
|
1309
|
+
// [
|
|
1310
|
+
// { instant: "2024-03-10T07:00:00Z", offsetBefore: "-05:00", offsetAfter: "-04:00" },
|
|
1311
|
+
// { instant: "2024-11-03T06:00:00Z", offsetBefore: "-04:00", offsetAfter: "-05:00" }
|
|
1312
|
+
// ]
|
|
1313
|
+
|
|
1314
|
+
getDstTransitions("Asia/Tokyo", 2024);
|
|
1315
|
+
// []
|
|
1316
|
+
|
|
1317
|
+
getDstTransitions("Invalid/Zone", 2024);
|
|
1318
|
+
// []
|
|
1319
|
+
```
|
|
1320
|
+
|
|
1321
|
+
Each object's `instant` is a UTC ISO 8601 string; `offsetBefore`/`offsetAfter` are `±HH:MM` offset strings. Returns `[]` for zones with no transitions in the requested year and on invalid input.
|
|
1322
|
+
|
|
1323
|
+
**Four DST-related questions, four different functions.** The names are close enough to be misread, so here's the map:
|
|
1324
|
+
|
|
1325
|
+
| Question | Function | Scope |
|
|
1326
|
+
| ------------------------------------------------------------------------------- | --------------------------------------------- | ---------------------------------------------------- |
|
|
1327
|
+
| Does this zone observe DST at all? | `hasDaylightSaving(timeZone)` | Zone-level, no instant |
|
|
1328
|
+
| Where do this zone's transitions fall? | `getDstTransitions(timeZone, year)` | Enumerates instants |
|
|
1329
|
+
| Is _this particular instant_ currently in DST? | `isInDaylightSaving(value)` | A single zoned value |
|
|
1330
|
+
| What should happen when construction lands on an ambiguous/nonexistent instant? | `disambiguation` / `offset` options (Group C) | Orthogonal — a construction-time choice, not a query |
|
|
1331
|
+
|
|
1332
|
+
`isInDaylightSaving` answers the third question:
|
|
1333
|
+
|
|
1334
|
+
```typescript
|
|
1335
|
+
import { isInDaylightSaving } from "@northguild/gmt/zoned";
|
|
1336
|
+
|
|
1337
|
+
isInDaylightSaving("2024-07-15T12:00:00-04:00[America/New_York]");
|
|
1338
|
+
// true
|
|
1339
|
+
|
|
1340
|
+
isInDaylightSaving("2024-01-15T12:00:00-05:00[America/New_York]");
|
|
1341
|
+
// false
|
|
1342
|
+
|
|
1343
|
+
// Southern-hemisphere DST spans the new year.
|
|
1344
|
+
isInDaylightSaving("2024-01-15T12:00:00+11:00[Australia/Sydney]");
|
|
1345
|
+
// true
|
|
1346
|
+
|
|
1347
|
+
isInDaylightSaving("2024-07-15T12:00:00+09:00[Asia/Tokyo]");
|
|
1348
|
+
// false — Asia/Tokyo has no DST, so this is always false
|
|
1349
|
+
|
|
1350
|
+
isInDaylightSaving("invalid");
|
|
1351
|
+
// false
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1354
|
+
`getZonedOffset` and `getZonedOffsetAs` read a zoned value's UTC offset — the former as a `±HH:MM` string, the latter as a number in minutes or nanoseconds:
|
|
1355
|
+
|
|
1356
|
+
```typescript
|
|
1357
|
+
import { getZonedOffset, getZonedOffsetAs } from "@northguild/gmt/zoned";
|
|
1358
|
+
|
|
1359
|
+
getZonedOffset("2024-07-15T12:00:00-04:00[America/New_York]");
|
|
1360
|
+
// "-04:00"
|
|
1361
|
+
|
|
1362
|
+
getZonedOffsetAs("2024-07-15T12:00:00-04:00[America/New_York]", "minutes");
|
|
1363
|
+
// -240
|
|
1364
|
+
|
|
1365
|
+
getZonedOffsetAs("2024-05-15T12:00:00+05:45[Asia/Kathmandu]", "minutes");
|
|
1366
|
+
// 345 — GMT has half- and quarter-hour offsets too, not just whole hours
|
|
1367
|
+
|
|
1368
|
+
getZonedOffset("invalid");
|
|
1369
|
+
// ""
|
|
1370
|
+
```
|
|
1371
|
+
|
|
1372
|
+
`getTimeZoneOffset` looks up a timezone's offset at a given instant without needing an existing zoned value in hand:
|
|
1373
|
+
|
|
1374
|
+
```typescript
|
|
1375
|
+
import { getTimeZoneOffset } from "@northguild/gmt/zoned";
|
|
1376
|
+
|
|
1377
|
+
getTimeZoneOffset("America/New_York", "2024-07-15T12:00:00Z");
|
|
1378
|
+
// "-04:00"
|
|
1379
|
+
|
|
1380
|
+
getTimeZoneOffset("America/New_York", "2024-01-15T12:00:00Z");
|
|
1381
|
+
// "-05:00"
|
|
1382
|
+
|
|
1383
|
+
getTimeZoneOffset("Invalid/Zone", "2024-07-15T12:00:00Z");
|
|
1384
|
+
// ""
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
`formatTimeZoneName` returns a timezone's localized display name. `options.style` covers every `Intl.DateTimeFormatOptions` `timeZoneName` value:
|
|
1388
|
+
|
|
1389
|
+
```typescript
|
|
1390
|
+
import { formatTimeZoneName } from "@northguild/gmt/zoned";
|
|
1391
|
+
|
|
1392
|
+
formatTimeZoneName("America/New_York", "en-US", { style: "shortGeneric" });
|
|
1393
|
+
// "ET" — season-independent
|
|
1394
|
+
|
|
1395
|
+
formatTimeZoneName("America/New_York", "en-US", { style: "longGeneric" });
|
|
1396
|
+
// "Eastern Time" — season-independent
|
|
1397
|
+
|
|
1398
|
+
formatTimeZoneName("America/New_York", "en-US", { style: "long" });
|
|
1399
|
+
// "Eastern Standard Time" or "Eastern Daylight Time", depending on the current date
|
|
1400
|
+
|
|
1401
|
+
formatTimeZoneName("Invalid/Zone", "en-US");
|
|
1402
|
+
// ""
|
|
1403
|
+
```
|
|
1404
|
+
|
|
1405
|
+
The `"short"`/`"long"`/`"shortOffset"`/`"longOffset"` styles name the zone's _current_ offset — for a DST-observing zone the label flips between standard and daylight names depending on when this is called, since there's no instant parameter to pin it to (this matches how `Intl.DateTimeFormat.prototype.format()` itself defaults to "now" with no argument). The `"shortGeneric"`/`"longGeneric"` styles are season-independent and don't have this issue — prefer them for a name that won't change twice a year.
|
|
1406
|
+
|
|
1407
|
+
`clampZoned` restricts a zoned datetime to a range, and `closestZonedTo` finds the nearest candidate by temporal distance:
|
|
1408
|
+
|
|
1409
|
+
```typescript
|
|
1410
|
+
import { clampZoned, closestZonedTo } from "@northguild/gmt";
|
|
1411
|
+
|
|
1412
|
+
clampZoned(
|
|
1413
|
+
"2024-02-01T12:00:00[America/New_York]",
|
|
1414
|
+
"2024-03-01T00:00:00[America/New_York]",
|
|
1415
|
+
"2024-03-31T23:59:59[America/New_York]",
|
|
1416
|
+
);
|
|
1417
|
+
// "2024-03-01T00:00:00-05:00[America/New_York]"
|
|
1418
|
+
|
|
1419
|
+
closestZonedTo("2024-03-15T12:00:00[America/New_York]", [
|
|
1420
|
+
"2024-03-01T00:00:00[America/New_York]",
|
|
1421
|
+
"2024-03-20T00:00:00[America/New_York]",
|
|
1422
|
+
"2024-03-18T00:00:00[America/New_York]",
|
|
1423
|
+
]);
|
|
1424
|
+
// "2024-03-18T00:00:00-04:00[America/New_York]"
|
|
1425
|
+
```
|
|
1426
|
+
|
|
1427
|
+
See [`docs/dst-disambiguation.md`](../../docs/dst-disambiguation.md) for the full explanation, including why `overflow` was deliberately left off the public API.
|
|
1428
|
+
|
|
1429
|
+
### Formatting
|
|
1430
|
+
|
|
1431
|
+
```typescript
|
|
1432
|
+
import {
|
|
1433
|
+
formatDate,
|
|
1434
|
+
formatRelativeDate,
|
|
1435
|
+
formatTime,
|
|
1436
|
+
formatRelativeTime,
|
|
1437
|
+
formatDateTime,
|
|
1438
|
+
formatRelativeDateTime,
|
|
1439
|
+
formatCalendar,
|
|
1440
|
+
formatDateRange,
|
|
1441
|
+
formatDateTimeRange,
|
|
1442
|
+
formatDateToParts,
|
|
1443
|
+
formatDateTimeToParts,
|
|
1444
|
+
formatZonedDateTime,
|
|
1445
|
+
formatZonedRange,
|
|
1446
|
+
formatZonedToParts,
|
|
1447
|
+
formatRelativeZoned,
|
|
1448
|
+
formatCalendarZoned,
|
|
1449
|
+
formatUtc,
|
|
1450
|
+
formatRelativeUtc,
|
|
1451
|
+
formatCalendarUtc,
|
|
1452
|
+
formatUnix,
|
|
1453
|
+
formatRelativeUnix,
|
|
1454
|
+
formatCalendarUnix,
|
|
1455
|
+
} from "@northguild/gmt";
|
|
1456
|
+
|
|
1457
|
+
// Relative to "now" — auto-picks the best unit.
|
|
1458
|
+
formatRelativeDate("2026-01-15");
|
|
1459
|
+
// e.g. "3 months ago"
|
|
1460
|
+
|
|
1461
|
+
formatRelativeTime("14:30:00", "en-US", { style: "short" });
|
|
1462
|
+
// e.g. "2 hours ago"
|
|
1463
|
+
|
|
1464
|
+
formatRelativeDateTime("2026-03-17T09:00:00", "en-GB", {
|
|
1465
|
+
style: "long",
|
|
1466
|
+
numeric: "always",
|
|
1467
|
+
});
|
|
1468
|
+
// e.g. "17 March, 2026 at 09:00"
|
|
1469
|
+
|
|
1470
|
+
// Zoned relative formatting — reference can be a ZonedDateTime, UTC string, or unix epoch.
|
|
1471
|
+
formatRelativeZoned("2026-03-08T01:00:00-05:00[America/New_York]", "en-US");
|
|
1472
|
+
// e.g. "tomorrow"
|
|
1473
|
+
|
|
1474
|
+
formatRelativeUtc("2024-03-17T14:30:45+00:00[UTC]", "en-US");
|
|
1475
|
+
// e.g. "2 years ago"
|
|
1476
|
+
|
|
1477
|
+
// Unix epoch relative formatting.
|
|
1478
|
+
formatRelativeUnix(1710685845000, "en-US", { epochUnit: "milliseconds" });
|
|
1479
|
+
// e.g. "3 years ago"
|
|
1480
|
+
|
|
1481
|
+
// roundingMethod ("floor" | "ceil" | "round", default "round") controls how the
|
|
1482
|
+
// computed distance rounds to the display unit — every formatRelative* function accepts it.
|
|
1483
|
+
formatRelativeUtc(value, "en-US", { roundingMethod: "floor" });
|
|
1484
|
+
|
|
1485
|
+
// formatCalendar* — a relative day label + time-of-day, joined with the
|
|
1486
|
+
// locale's own connector (never a hardcoded "at"). Distinct from
|
|
1487
|
+
// formatRelative*'s elapsed-time phrasing ("in 1 day"): this is Moment's
|
|
1488
|
+
// `.calendar()` — for user-facing schedules, not elapsed-time displays.
|
|
1489
|
+
// Within ±6 days of "now" (or an explicit `reference`) it stays relative;
|
|
1490
|
+
// beyond that it falls back to an absolute date + time, no relative wording.
|
|
1491
|
+
formatCalendar("2026-03-16T14:30:00", "en-US", {
|
|
1492
|
+
reference: "2026-03-15T09:00:00",
|
|
1493
|
+
});
|
|
1494
|
+
// "tomorrow at 2:30 PM"
|
|
1495
|
+
|
|
1496
|
+
formatCalendar("2026-03-08T14:30:00", "en-US", {
|
|
1497
|
+
reference: "2026-03-15T09:00:00",
|
|
1498
|
+
});
|
|
1499
|
+
// "March 8, 2026 at 2:30 PM" — 7 days out, beyond the threshold
|
|
1500
|
+
|
|
1501
|
+
formatCalendarZoned("2026-03-16T14:30:00-04:00[America/New_York]", "de-DE", {
|
|
1502
|
+
reference: "2026-03-15T09:00:00-04:00[America/New_York]",
|
|
1503
|
+
});
|
|
1504
|
+
// "morgen um 14:30" — locale's own connector, not "at"
|
|
1505
|
+
|
|
1506
|
+
// formatDateRange / formatDateTimeRange — plain counterparts of
|
|
1507
|
+
// formatZonedRange (same parameter order and option shape), for a
|
|
1508
|
+
// locale-elided range between two timezone-free values.
|
|
1509
|
+
formatDateRange("2024-02-03", "2024-02-05", "en-US", { dateStyle: "long" });
|
|
1510
|
+
// "February 3 – 5, 2024"
|
|
1511
|
+
|
|
1512
|
+
formatDateTimeRange("2024-02-03T09:00:00", "2024-02-03T17:00:00", "en-US", {
|
|
1513
|
+
dateStyle: "long",
|
|
1514
|
+
timeStyle: "short",
|
|
1515
|
+
});
|
|
1516
|
+
// "February 3, 2024, 9:00 AM – 5:00 PM"
|
|
1517
|
+
|
|
1518
|
+
// formatDateToParts / formatDateTimeToParts / formatZonedToParts return the
|
|
1519
|
+
// locale-ordered Array<{ type, value }> parts behind the strings above,
|
|
1520
|
+
// instead of a finished string — GMT's substitute for a token formatter.
|
|
1521
|
+
// Iterate the array as returned; reassembling parts in a fixed order
|
|
1522
|
+
// reintroduces the locale-ordering bug formatToParts exists to avoid.
|
|
1523
|
+
formatDateToParts("2024-03-15", "en-US");
|
|
1524
|
+
// [{ type: "month", value: "3" }, { type: "literal", value: "/" },
|
|
1525
|
+
// { type: "day", value: "15" }, { type: "literal", value: "/" },
|
|
1526
|
+
// { type: "year", value: "2024" }]
|
|
1527
|
+
|
|
1528
|
+
formatDateToParts("2024-03-15", "fr-FR");
|
|
1529
|
+
// day comes before month, same locale-order guarantee as formatDate:
|
|
1530
|
+
// [{ type: "day", value: "15" }, { type: "literal", value: "/" },
|
|
1531
|
+
// { type: "month", value: "3" }, { type: "literal", value: "/" },
|
|
1532
|
+
// { type: "year", value: "2024" }]
|
|
1533
|
+
|
|
1534
|
+
formatZonedToParts("2024-03-15T14:30:00-04:00[America/New_York]", "en-US", {
|
|
1535
|
+
timeZoneName: "longOffset",
|
|
1536
|
+
});
|
|
1537
|
+
// includes { type: "timeZoneName", value: "GMT-4" }
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
### Named machine formats
|
|
1541
|
+
|
|
1542
|
+
Fixed, non-locale-adaptive grammars for interchange with email, HTTP, SQL, and
|
|
1543
|
+
RFC 3339 consumers — none of these take a `locale` argument, since the
|
|
1544
|
+
grammar itself is constant (English weekday/month names where the format
|
|
1545
|
+
mandates them).
|
|
1546
|
+
|
|
1547
|
+
```typescript
|
|
1548
|
+
import {
|
|
1549
|
+
formatRfc2822,
|
|
1550
|
+
parseRfc2822,
|
|
1551
|
+
formatHttp,
|
|
1552
|
+
parseHttp,
|
|
1553
|
+
formatSql,
|
|
1554
|
+
parseSql,
|
|
1555
|
+
formatRfc3339,
|
|
1556
|
+
parseRfc3339,
|
|
1557
|
+
} from "@northguild/gmt";
|
|
1558
|
+
|
|
1559
|
+
// Email `Date:` headers (RFC 5322 / RFC 2822).
|
|
1560
|
+
formatRfc2822("2024-03-15T14:30:00-04:00[America/New_York]");
|
|
1561
|
+
// "Fri, 15 Mar 2024 14:30:00 -0400"
|
|
1562
|
+
parseRfc2822("Fri, 15 Mar 2024 14:30:00 -0400");
|
|
1563
|
+
// "2024-03-15T14:30:00-04:00[-04:00]"
|
|
1564
|
+
|
|
1565
|
+
// HTTP headers (RFC 7231 IMF-fixdate) — Last-Modified, Date, Expires.
|
|
1566
|
+
formatHttp("2024-03-15T14:30:00Z");
|
|
1567
|
+
// "Fri, 15 Mar 2024 14:30:00 GMT"
|
|
1568
|
+
parseHttp("Fri, 15 Mar 2024 14:30:00 GMT");
|
|
1569
|
+
// "2024-03-15T14:30:00Z"
|
|
1570
|
+
|
|
1571
|
+
// ANSI SQL / ODBC datetime literals (DATETIME/TIMESTAMP columns, no tz).
|
|
1572
|
+
formatSql("2024-03-15T14:30:00");
|
|
1573
|
+
// "2024-03-15 14:30:00"
|
|
1574
|
+
parseSql("2024-03-15 14:30:00");
|
|
1575
|
+
// "2024-03-15T14:30:00"
|
|
1576
|
+
|
|
1577
|
+
// Strict RFC 3339 — strips the bracketed IANA zone GMT's own zoned strings
|
|
1578
|
+
// carry, which RFC 3339 does not permit.
|
|
1579
|
+
formatRfc3339("2024-03-15T14:30:00-04:00[America/New_York]");
|
|
1580
|
+
// "2024-03-15T14:30:00-04:00"
|
|
1581
|
+
parseRfc3339("2024-03-15T14:30:00-04:00");
|
|
1582
|
+
// "2024-03-15T14:30:00-04:00[-04:00]"
|
|
1583
|
+
```
|
|
1584
|
+
|
|
1585
|
+
### Unix and UTC helpers
|
|
1586
|
+
|
|
1587
|
+
```typescript
|
|
1588
|
+
import { getUnixNow, getUtcNow, convertUnixToPlainDate } from "@northguild/gmt";
|
|
1589
|
+
|
|
1590
|
+
getUnixNow("milliseconds");
|
|
1591
|
+
// 1710685845000
|
|
1592
|
+
|
|
1593
|
+
getUtcNow();
|
|
1594
|
+
// "2026-03-18T11:42:33.123Z"
|
|
1595
|
+
|
|
1596
|
+
convertUnixToPlainDate(1710685845);
|
|
1597
|
+
// "2024-03-17"
|
|
1598
|
+
```
|
|
1599
|
+
|
|
1600
|
+
## API Surface
|
|
1601
|
+
|
|
1602
|
+
For the complete API listing, see the namespace documentation on GitHub:
|
|
1603
|
+
|
|
1604
|
+
- [Duration API](https://github.com/northguild/gmt/tree/main/packages/gmt/src/duration) — ISO 8601 duration parsing, validation, arithmetic, and formatting
|
|
1605
|
+
- [Plain API](https://github.com/northguild/gmt/tree/main/packages/gmt/src/plain) — timezone-free operations
|
|
1606
|
+
- [Zoned API](https://github.com/northguild/gmt/tree/main/packages/gmt/src/zoned) — IANA timezone-aware operations
|
|
1607
|
+
- [Unix API](https://github.com/northguild/gmt/tree/main/packages/gmt/src/unix) — Unix epoch utilities
|
|
1608
|
+
- [UTC API](https://github.com/northguild/gmt/tree/main/packages/gmt/src/utc) — UTC instant utilities
|
|
1609
|
+
- [Regex API](https://github.com/northguild/gmt/tree/main/packages/gmt/src/regex) — composable regex patterns
|
|
1610
|
+
|
|
1611
|
+
## Agent Prompt
|
|
1612
|
+
|
|
1613
|
+
When working with `@northguild/gmt`, follow these rules:
|
|
1614
|
+
|
|
1615
|
+
1. **No `Date` object.** Use `Temporal` exclusively.
|
|
1616
|
+
2. **String-in, string-out.** Public APIs accept ISO 8601 strings; return strings, numbers, booleans, or arrays.
|
|
1617
|
+
3. **Invalid input returns a sentinel, never throws.** `""` for strings, `null` for numbers, `false` for booleans, `[]` for arrays.
|
|
1618
|
+
4. **Wrap all Temporal calls in `try-catch`.** `.from()`, `.add()`, `.since()`, etc. throw `RangeError` on bad input.
|
|
1619
|
+
5. **Keep `plain/` and `zoned/` strictly separate.** Never mix `PlainDateTime` and `ZonedDateTime`.
|
|
1620
|
+
6. **Full locale matrix for any locale-aware function.** 17 locales, explicit rows, `hasFullIcu` ternaries where output differs.
|
|
1621
|
+
7. **Use pre-built mocks for error-path tests.** See `packages/gmt/src/test/mocks`.
|
|
1622
|
+
8. **JSDoc with `@example` on every public function.** Cover valid, invalid, and edge-case inputs.
|
|
1623
|
+
|
|
1624
|
+
## License
|
|
1625
|
+
|
|
1626
|
+
MIT — See [LICENSE](../../LICENSE) for details.
|