@cdx-ui/formatters 0.0.1-beta.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/lib/commonjs/dates/calendar/formatCalendarMonthYear.js +28 -0
- package/lib/commonjs/dates/calendar/formatCalendarMonthYear.js.map +1 -0
- package/lib/commonjs/dates/calendar/formatDateTimeListDateRow.js +40 -0
- package/lib/commonjs/dates/calendar/formatDateTimeListDateRow.js.map +1 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarMonth.js +28 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarMonth.js.map +1 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarYear.js +16 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarYear.js.map +1 -0
- package/lib/commonjs/dates/calendar/getCalendarWeekdayLabels.js +23 -0
- package/lib/commonjs/dates/calendar/getCalendarWeekdayLabels.js.map +1 -0
- package/lib/commonjs/dates/datetime/clampDateTimeId.js +27 -0
- package/lib/commonjs/dates/datetime/clampDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/compareDateTimeIds.js +28 -0
- package/lib/commonjs/dates/datetime/compareDateTimeIds.js.map +1 -0
- package/lib/commonjs/dates/datetime/dateTimeId.js +38 -0
- package/lib/commonjs/dates/datetime/dateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeId.js +27 -0
- package/lib/commonjs/dates/datetime/formatDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListHour.js +21 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListHour.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListMinute.js +16 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListMinute.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListPeriod.js +17 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListPeriod.js.map +1 -0
- package/lib/commonjs/dates/datetime/isLocaleHour12.js +30 -0
- package/lib/commonjs/dates/datetime/isLocaleHour12.js.map +1 -0
- package/lib/commonjs/dates/datetime/isValidDateTimeId.js +23 -0
- package/lib/commonjs/dates/datetime/isValidDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/nowDateTimeId.js +57 -0
- package/lib/commonjs/dates/datetime/nowDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/parseDateTimeId.js +29 -0
- package/lib/commonjs/dates/datetime/parseDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/display/formatDateForDisplay.js +28 -0
- package/lib/commonjs/dates/display/formatDateForDisplay.js.map +1 -0
- package/lib/commonjs/dates/display/formatDateRangeForDisplay.js +25 -0
- package/lib/commonjs/dates/display/formatDateRangeForDisplay.js.map +1 -0
- package/lib/commonjs/dates/display/formatDateTimeForDisplay.js +34 -0
- package/lib/commonjs/dates/display/formatDateTimeForDisplay.js.map +1 -0
- package/lib/commonjs/dates/display/formatMonthForDisplay.js +33 -0
- package/lib/commonjs/dates/display/formatMonthForDisplay.js.map +1 -0
- package/lib/commonjs/dates/index.js +367 -0
- package/lib/commonjs/dates/index.js.map +1 -0
- package/lib/commonjs/dates/internal/brand.js +19 -0
- package/lib/commonjs/dates/internal/brand.js.map +1 -0
- package/lib/commonjs/dates/internal/calendarHelpers.js +22 -0
- package/lib/commonjs/dates/internal/calendarHelpers.js.map +1 -0
- package/lib/commonjs/dates/internal/clampHelpers.js +20 -0
- package/lib/commonjs/dates/internal/clampHelpers.js.map +1 -0
- package/lib/commonjs/dates/internal/dateIdToNativeDate.js +20 -0
- package/lib/commonjs/dates/internal/dateIdToNativeDate.js.map +1 -0
- package/lib/commonjs/dates/internal/intlCache.js +52 -0
- package/lib/commonjs/dates/internal/intlCache.js.map +1 -0
- package/lib/commonjs/dates/internal/intlCopy.js +72 -0
- package/lib/commonjs/dates/internal/intlCopy.js.map +1 -0
- package/lib/commonjs/dates/internal/segmentBuilders.js +98 -0
- package/lib/commonjs/dates/internal/segmentBuilders.js.map +1 -0
- package/lib/commonjs/dates/labels/dateComponentLabels.js +57 -0
- package/lib/commonjs/dates/labels/dateComponentLabels.js.map +1 -0
- package/lib/commonjs/dates/ranges/compareDateIds.js +26 -0
- package/lib/commonjs/dates/ranges/compareDateIds.js.map +1 -0
- package/lib/commonjs/dates/ranges/compareMonthIds.js +31 -0
- package/lib/commonjs/dates/ranges/compareMonthIds.js.map +1 -0
- package/lib/commonjs/dates/ranges/dateRangeAroundDay.js +25 -0
- package/lib/commonjs/dates/ranges/dateRangeAroundDay.js.map +1 -0
- package/lib/commonjs/dates/ranges/dateRangeFromLastNDays.js +28 -0
- package/lib/commonjs/dates/ranges/dateRangeFromLastNDays.js.map +1 -0
- package/lib/commonjs/dates/ranges/eachDateIdInRange.js +29 -0
- package/lib/commonjs/dates/ranges/eachDateIdInRange.js.map +1 -0
- package/lib/commonjs/dates/ranges/normalizeDateRange.js +23 -0
- package/lib/commonjs/dates/ranges/normalizeDateRange.js.map +1 -0
- package/lib/commonjs/dates/segments/applyDateSegmentChange.js +77 -0
- package/lib/commonjs/dates/segments/applyDateSegmentChange.js.map +1 -0
- package/lib/commonjs/dates/segments/formatDateSegment.js +19 -0
- package/lib/commonjs/dates/segments/formatDateSegment.js.map +1 -0
- package/lib/commonjs/dates/segments/getDateFieldSegments.js +44 -0
- package/lib/commonjs/dates/segments/getDateFieldSegments.js.map +1 -0
- package/lib/commonjs/dates/segments/getDateTimeFieldSegments.js +150 -0
- package/lib/commonjs/dates/segments/getDateTimeFieldSegments.js.map +1 -0
- package/lib/commonjs/dates/segments/getDateTimeSegmentVisibility.js +15 -0
- package/lib/commonjs/dates/segments/getDateTimeSegmentVisibility.js.map +1 -0
- package/lib/commonjs/dates/segments/getEmptyDateSegmentText.js +17 -0
- package/lib/commonjs/dates/segments/getEmptyDateSegmentText.js.map +1 -0
- package/lib/commonjs/dates/segments/parseDateSegment.js +26 -0
- package/lib/commonjs/dates/segments/parseDateSegment.js.map +1 -0
- package/lib/commonjs/dates/types.js +2 -0
- package/lib/commonjs/dates/types.js.map +1 -0
- package/lib/commonjs/dates/wire/clampDateParts.js +26 -0
- package/lib/commonjs/dates/wire/clampDateParts.js.map +1 -0
- package/lib/commonjs/dates/wire/clampMonthParts.js +23 -0
- package/lib/commonjs/dates/wire/clampMonthParts.js.map +1 -0
- package/lib/commonjs/dates/wire/dateId.js +50 -0
- package/lib/commonjs/dates/wire/dateId.js.map +1 -0
- package/lib/commonjs/dates/wire/formatDateId.js +25 -0
- package/lib/commonjs/dates/wire/formatDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/formatMonthId.js +21 -0
- package/lib/commonjs/dates/wire/formatMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidDateId.js +27 -0
- package/lib/commonjs/dates/wire/isValidDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidDateParts.js +18 -0
- package/lib/commonjs/dates/wire/isValidDateParts.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidMonthId.js +27 -0
- package/lib/commonjs/dates/wire/isValidMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidMonthParts.js +16 -0
- package/lib/commonjs/dates/wire/isValidMonthParts.js.map +1 -0
- package/lib/commonjs/dates/wire/monthId.js +47 -0
- package/lib/commonjs/dates/wire/monthId.js.map +1 -0
- package/lib/commonjs/dates/wire/parseDateId.js +29 -0
- package/lib/commonjs/dates/wire/parseDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/parseMonthId.js +28 -0
- package/lib/commonjs/dates/wire/parseMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/toMonthId.js +22 -0
- package/lib/commonjs/dates/wire/toMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/todayDateId.js +17 -0
- package/lib/commonjs/dates/wire/todayDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/todayMonthId.js +17 -0
- package/lib/commonjs/dates/wire/todayMonthId.js.map +1 -0
- package/lib/commonjs/formatNumber.js +50 -0
- package/lib/commonjs/formatNumber.js.map +1 -0
- package/lib/commonjs/index.js +326 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +33 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/dates/calendar/formatCalendarMonthYear.js +24 -0
- package/lib/module/dates/calendar/formatCalendarMonthYear.js.map +1 -0
- package/lib/module/dates/calendar/formatDateTimeListDateRow.js +36 -0
- package/lib/module/dates/calendar/formatDateTimeListDateRow.js.map +1 -0
- package/lib/module/dates/calendar/formatMonthCalendarMonth.js +24 -0
- package/lib/module/dates/calendar/formatMonthCalendarMonth.js.map +1 -0
- package/lib/module/dates/calendar/formatMonthCalendarYear.js +12 -0
- package/lib/module/dates/calendar/formatMonthCalendarYear.js.map +1 -0
- package/lib/module/dates/calendar/getCalendarWeekdayLabels.js +19 -0
- package/lib/module/dates/calendar/getCalendarWeekdayLabels.js.map +1 -0
- package/lib/module/dates/datetime/clampDateTimeId.js +24 -0
- package/lib/module/dates/datetime/clampDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/compareDateTimeIds.js +24 -0
- package/lib/module/dates/datetime/compareDateTimeIds.js.map +1 -0
- package/lib/module/dates/datetime/dateTimeId.js +35 -0
- package/lib/module/dates/datetime/dateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeId.js +23 -0
- package/lib/module/dates/datetime/formatDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeListHour.js +17 -0
- package/lib/module/dates/datetime/formatDateTimeListHour.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeListMinute.js +12 -0
- package/lib/module/dates/datetime/formatDateTimeListMinute.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeListPeriod.js +13 -0
- package/lib/module/dates/datetime/formatDateTimeListPeriod.js.map +1 -0
- package/lib/module/dates/datetime/isLocaleHour12.js +26 -0
- package/lib/module/dates/datetime/isLocaleHour12.js.map +1 -0
- package/lib/module/dates/datetime/isValidDateTimeId.js +19 -0
- package/lib/module/dates/datetime/isValidDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/nowDateTimeId.js +54 -0
- package/lib/module/dates/datetime/nowDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/parseDateTimeId.js +26 -0
- package/lib/module/dates/datetime/parseDateTimeId.js.map +1 -0
- package/lib/module/dates/display/formatDateForDisplay.js +24 -0
- package/lib/module/dates/display/formatDateForDisplay.js.map +1 -0
- package/lib/module/dates/display/formatDateRangeForDisplay.js +22 -0
- package/lib/module/dates/display/formatDateRangeForDisplay.js.map +1 -0
- package/lib/module/dates/display/formatDateTimeForDisplay.js +30 -0
- package/lib/module/dates/display/formatDateTimeForDisplay.js.map +1 -0
- package/lib/module/dates/display/formatMonthForDisplay.js +29 -0
- package/lib/module/dates/display/formatMonthForDisplay.js.map +1 -0
- package/lib/module/dates/index.js +59 -0
- package/lib/module/dates/index.js.map +1 -0
- package/lib/module/dates/internal/brand.js +12 -0
- package/lib/module/dates/internal/brand.js.map +1 -0
- package/lib/module/dates/internal/calendarHelpers.js +19 -0
- package/lib/module/dates/internal/calendarHelpers.js.map +1 -0
- package/lib/module/dates/internal/clampHelpers.js +14 -0
- package/lib/module/dates/internal/clampHelpers.js.map +1 -0
- package/lib/module/dates/internal/dateIdToNativeDate.js +16 -0
- package/lib/module/dates/internal/dateIdToNativeDate.js.map +1 -0
- package/lib/module/dates/internal/intlCache.js +47 -0
- package/lib/module/dates/internal/intlCache.js.map +1 -0
- package/lib/module/dates/internal/intlCopy.js +66 -0
- package/lib/module/dates/internal/intlCopy.js.map +1 -0
- package/lib/module/dates/internal/segmentBuilders.js +91 -0
- package/lib/module/dates/internal/segmentBuilders.js.map +1 -0
- package/lib/module/dates/labels/dateComponentLabels.js +50 -0
- package/lib/module/dates/labels/dateComponentLabels.js.map +1 -0
- package/lib/module/dates/ranges/compareDateIds.js +22 -0
- package/lib/module/dates/ranges/compareDateIds.js.map +1 -0
- package/lib/module/dates/ranges/compareMonthIds.js +27 -0
- package/lib/module/dates/ranges/compareMonthIds.js.map +1 -0
- package/lib/module/dates/ranges/dateRangeAroundDay.js +21 -0
- package/lib/module/dates/ranges/dateRangeAroundDay.js.map +1 -0
- package/lib/module/dates/ranges/dateRangeFromLastNDays.js +24 -0
- package/lib/module/dates/ranges/dateRangeFromLastNDays.js.map +1 -0
- package/lib/module/dates/ranges/eachDateIdInRange.js +26 -0
- package/lib/module/dates/ranges/eachDateIdInRange.js.map +1 -0
- package/lib/module/dates/ranges/normalizeDateRange.js +20 -0
- package/lib/module/dates/ranges/normalizeDateRange.js.map +1 -0
- package/lib/module/dates/segments/applyDateSegmentChange.js +73 -0
- package/lib/module/dates/segments/applyDateSegmentChange.js.map +1 -0
- package/lib/module/dates/segments/formatDateSegment.js +15 -0
- package/lib/module/dates/segments/formatDateSegment.js.map +1 -0
- package/lib/module/dates/segments/getDateFieldSegments.js +40 -0
- package/lib/module/dates/segments/getDateFieldSegments.js.map +1 -0
- package/lib/module/dates/segments/getDateTimeFieldSegments.js +147 -0
- package/lib/module/dates/segments/getDateTimeFieldSegments.js.map +1 -0
- package/lib/module/dates/segments/getDateTimeSegmentVisibility.js +11 -0
- package/lib/module/dates/segments/getDateTimeSegmentVisibility.js.map +1 -0
- package/lib/module/dates/segments/getEmptyDateSegmentText.js +13 -0
- package/lib/module/dates/segments/getEmptyDateSegmentText.js.map +1 -0
- package/lib/module/dates/segments/parseDateSegment.js +22 -0
- package/lib/module/dates/segments/parseDateSegment.js.map +1 -0
- package/lib/module/dates/types.js +2 -0
- package/lib/module/dates/types.js.map +1 -0
- package/lib/module/dates/wire/clampDateParts.js +22 -0
- package/lib/module/dates/wire/clampDateParts.js.map +1 -0
- package/lib/module/dates/wire/clampMonthParts.js +19 -0
- package/lib/module/dates/wire/clampMonthParts.js.map +1 -0
- package/lib/module/dates/wire/dateId.js +47 -0
- package/lib/module/dates/wire/dateId.js.map +1 -0
- package/lib/module/dates/wire/formatDateId.js +22 -0
- package/lib/module/dates/wire/formatDateId.js.map +1 -0
- package/lib/module/dates/wire/formatMonthId.js +17 -0
- package/lib/module/dates/wire/formatMonthId.js.map +1 -0
- package/lib/module/dates/wire/isValidDateId.js +23 -0
- package/lib/module/dates/wire/isValidDateId.js.map +1 -0
- package/lib/module/dates/wire/isValidDateParts.js +14 -0
- package/lib/module/dates/wire/isValidDateParts.js.map +1 -0
- package/lib/module/dates/wire/isValidMonthId.js +23 -0
- package/lib/module/dates/wire/isValidMonthId.js.map +1 -0
- package/lib/module/dates/wire/isValidMonthParts.js +12 -0
- package/lib/module/dates/wire/isValidMonthParts.js.map +1 -0
- package/lib/module/dates/wire/monthId.js +44 -0
- package/lib/module/dates/wire/monthId.js.map +1 -0
- package/lib/module/dates/wire/parseDateId.js +26 -0
- package/lib/module/dates/wire/parseDateId.js.map +1 -0
- package/lib/module/dates/wire/parseMonthId.js +25 -0
- package/lib/module/dates/wire/parseMonthId.js.map +1 -0
- package/lib/module/dates/wire/toMonthId.js +18 -0
- package/lib/module/dates/wire/toMonthId.js.map +1 -0
- package/lib/module/dates/wire/todayDateId.js +13 -0
- package/lib/module/dates/wire/todayDateId.js.map +1 -0
- package/lib/module/dates/wire/todayMonthId.js +13 -0
- package/lib/module/dates/wire/todayMonthId.js.map +1 -0
- package/lib/module/formatNumber.js +46 -0
- package/lib/module/formatNumber.js.map +1 -0
- package/lib/module/index.js +17 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +29 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/dates/calendar/formatCalendarMonthYear.d.ts +12 -0
- package/lib/typescript/dates/calendar/formatCalendarMonthYear.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/formatDateTimeListDateRow.d.ts +13 -0
- package/lib/typescript/dates/calendar/formatDateTimeListDateRow.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarMonth.d.ts +13 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarMonth.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarYear.d.ts +8 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarYear.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/getCalendarWeekdayLabels.d.ts +12 -0
- package/lib/typescript/dates/calendar/getCalendarWeekdayLabels.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/clampDateTimeId.d.ts +16 -0
- package/lib/typescript/dates/datetime/clampDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/compareDateTimeIds.d.ts +13 -0
- package/lib/typescript/dates/datetime/compareDateTimeIds.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/dateTimeId.d.ts +18 -0
- package/lib/typescript/dates/datetime/dateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeId.d.ts +12 -0
- package/lib/typescript/dates/datetime/formatDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeListHour.d.ts +11 -0
- package/lib/typescript/dates/datetime/formatDateTimeListHour.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeListMinute.d.ts +8 -0
- package/lib/typescript/dates/datetime/formatDateTimeListMinute.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeListPeriod.d.ts +9 -0
- package/lib/typescript/dates/datetime/formatDateTimeListPeriod.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/isLocaleHour12.d.ts +12 -0
- package/lib/typescript/dates/datetime/isLocaleHour12.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/isValidDateTimeId.d.ts +9 -0
- package/lib/typescript/dates/datetime/isValidDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/nowDateTimeId.d.ts +14 -0
- package/lib/typescript/dates/datetime/nowDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/parseDateTimeId.d.ts +9 -0
- package/lib/typescript/dates/datetime/parseDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatDateForDisplay.d.ts +13 -0
- package/lib/typescript/dates/display/formatDateForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatDateRangeForDisplay.d.ts +16 -0
- package/lib/typescript/dates/display/formatDateRangeForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatDateTimeForDisplay.d.ts +13 -0
- package/lib/typescript/dates/display/formatDateTimeForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatMonthForDisplay.d.ts +13 -0
- package/lib/typescript/dates/display/formatMonthForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/index.d.ts +58 -0
- package/lib/typescript/dates/index.d.ts.map +1 -0
- package/lib/typescript/dates/internal/brand.d.ts +11 -0
- package/lib/typescript/dates/internal/brand.d.ts.map +1 -0
- package/lib/typescript/dates/internal/calendarHelpers.d.ts +8 -0
- package/lib/typescript/dates/internal/calendarHelpers.d.ts.map +1 -0
- package/lib/typescript/dates/internal/clampHelpers.d.ts +5 -0
- package/lib/typescript/dates/internal/clampHelpers.d.ts.map +1 -0
- package/lib/typescript/dates/internal/dateIdToNativeDate.d.ts +12 -0
- package/lib/typescript/dates/internal/dateIdToNativeDate.d.ts.map +1 -0
- package/lib/typescript/dates/internal/intlCache.d.ts +12 -0
- package/lib/typescript/dates/internal/intlCache.d.ts.map +1 -0
- package/lib/typescript/dates/internal/intlCopy.d.ts +10 -0
- package/lib/typescript/dates/internal/intlCopy.d.ts.map +1 -0
- package/lib/typescript/dates/internal/segmentBuilders.d.ts +12 -0
- package/lib/typescript/dates/internal/segmentBuilders.d.ts.map +1 -0
- package/lib/typescript/dates/labels/dateComponentLabels.d.ts +31 -0
- package/lib/typescript/dates/labels/dateComponentLabels.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/compareDateIds.d.ts +10 -0
- package/lib/typescript/dates/ranges/compareDateIds.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/compareMonthIds.d.ts +10 -0
- package/lib/typescript/dates/ranges/compareMonthIds.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/dateRangeAroundDay.d.ts +14 -0
- package/lib/typescript/dates/ranges/dateRangeAroundDay.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/dateRangeFromLastNDays.d.ts +16 -0
- package/lib/typescript/dates/ranges/dateRangeFromLastNDays.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/eachDateIdInRange.d.ts +10 -0
- package/lib/typescript/dates/ranges/eachDateIdInRange.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/normalizeDateRange.d.ts +15 -0
- package/lib/typescript/dates/ranges/normalizeDateRange.d.ts.map +1 -0
- package/lib/typescript/dates/segments/applyDateSegmentChange.d.ts +21 -0
- package/lib/typescript/dates/segments/applyDateSegmentChange.d.ts.map +1 -0
- package/lib/typescript/dates/segments/formatDateSegment.d.ts +13 -0
- package/lib/typescript/dates/segments/formatDateSegment.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getDateFieldSegments.d.ts +13 -0
- package/lib/typescript/dates/segments/getDateFieldSegments.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getDateTimeFieldSegments.d.ts +14 -0
- package/lib/typescript/dates/segments/getDateTimeFieldSegments.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getDateTimeSegmentVisibility.d.ts +8 -0
- package/lib/typescript/dates/segments/getDateTimeSegmentVisibility.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getEmptyDateSegmentText.d.ts +9 -0
- package/lib/typescript/dates/segments/getEmptyDateSegmentText.d.ts.map +1 -0
- package/lib/typescript/dates/segments/parseDateSegment.d.ts +13 -0
- package/lib/typescript/dates/segments/parseDateSegment.d.ts.map +1 -0
- package/lib/typescript/dates/types.d.ts +66 -0
- package/lib/typescript/dates/types.d.ts.map +1 -0
- package/lib/typescript/dates/wire/clampDateParts.d.ts +12 -0
- package/lib/typescript/dates/wire/clampDateParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/clampMonthParts.d.ts +12 -0
- package/lib/typescript/dates/wire/clampMonthParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/dateId.d.ts +24 -0
- package/lib/typescript/dates/wire/dateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/formatDateId.d.ts +12 -0
- package/lib/typescript/dates/wire/formatDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/formatMonthId.d.ts +12 -0
- package/lib/typescript/dates/wire/formatMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidDateId.d.ts +13 -0
- package/lib/typescript/dates/wire/isValidDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidDateParts.d.ts +9 -0
- package/lib/typescript/dates/wire/isValidDateParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidMonthId.d.ts +13 -0
- package/lib/typescript/dates/wire/isValidMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidMonthParts.d.ts +9 -0
- package/lib/typescript/dates/wire/isValidMonthParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/monthId.d.ts +22 -0
- package/lib/typescript/dates/wire/monthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/parseDateId.d.ts +12 -0
- package/lib/typescript/dates/wire/parseDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/parseMonthId.d.ts +12 -0
- package/lib/typescript/dates/wire/parseMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/toMonthId.d.ts +12 -0
- package/lib/typescript/dates/wire/toMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/todayDateId.d.ts +8 -0
- package/lib/typescript/dates/wire/todayDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/todayMonthId.d.ts +8 -0
- package/lib/typescript/dates/wire/todayMonthId.d.ts.map +1 -0
- package/lib/typescript/formatNumber.d.ts +19 -0
- package/lib/typescript/formatNumber.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +2 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils.d.ts +10 -0
- package/lib/typescript/utils.d.ts.map +1 -0
- package/package.json +50 -0
- package/src/__tests__/applyDateSegmentChange.test.ts +26 -0
- package/src/__tests__/calendarFormatters.test.ts +35 -0
- package/src/__tests__/clampDateParts.test.ts +16 -0
- package/src/__tests__/compareDateIds.test.ts +7 -0
- package/src/__tests__/compareMonthIds.test.ts +19 -0
- package/src/__tests__/dateComponentLabels.test.ts +25 -0
- package/src/__tests__/dateRangeAroundDay.test.ts +10 -0
- package/src/__tests__/dateRangeFromLastNDays.test.ts +8 -0
- package/src/__tests__/dateSegmentHelpers.test.ts +24 -0
- package/src/__tests__/datetimeHelpers.test.ts +65 -0
- package/src/__tests__/displayFormatters.test.ts +34 -0
- package/src/__tests__/eachDateIdInRange.test.ts +11 -0
- package/src/__tests__/formatCalendarMonthYear.test.ts +9 -0
- package/src/__tests__/formatDateForDisplay.test.ts +11 -0
- package/src/__tests__/formatDateId.test.ts +15 -0
- package/src/__tests__/formatMonthId.test.ts +7 -0
- package/src/__tests__/formatNumber.test.ts +35 -0
- package/src/__tests__/getDateFieldSegments.test.ts +35 -0
- package/src/__tests__/getDateTimeFieldSegments.test.ts +140 -0
- package/src/__tests__/getDateTimeSegmentVisibility.test.ts +12 -0
- package/src/__tests__/intlCopy.test.ts +64 -0
- package/src/__tests__/isValidDateId.test.ts +8 -0
- package/src/__tests__/isValidMonthId.test.ts +8 -0
- package/src/__tests__/normalizeDateRange.test.ts +10 -0
- package/src/__tests__/toMonthId.test.ts +7 -0
- package/src/__tests__/todayDateId.test.ts +7 -0
- package/src/__tests__/wireConstructors.test.ts +74 -0
- package/src/dates/calendar/formatCalendarMonthYear.ts +21 -0
- package/src/dates/calendar/formatDateTimeListDateRow.ts +41 -0
- package/src/dates/calendar/formatMonthCalendarMonth.ts +21 -0
- package/src/dates/calendar/formatMonthCalendarYear.ts +9 -0
- package/src/dates/calendar/getCalendarWeekdayLabels.ts +23 -0
- package/src/dates/datetime/clampDateTimeId.ts +25 -0
- package/src/dates/datetime/compareDateTimeIds.ts +23 -0
- package/src/dates/datetime/dateTimeId.ts +36 -0
- package/src/dates/datetime/formatDateTimeId.ts +35 -0
- package/src/dates/datetime/formatDateTimeListHour.ts +14 -0
- package/src/dates/datetime/formatDateTimeListMinute.ts +9 -0
- package/src/dates/datetime/formatDateTimeListPeriod.ts +12 -0
- package/src/dates/datetime/isLocaleHour12.ts +23 -0
- package/src/dates/datetime/isValidDateTimeId.ts +18 -0
- package/src/dates/datetime/nowDateTimeId.ts +53 -0
- package/src/dates/datetime/parseDateTimeId.ts +24 -0
- package/src/dates/display/formatDateForDisplay.ts +21 -0
- package/src/dates/display/formatDateRangeForDisplay.ts +23 -0
- package/src/dates/display/formatDateTimeForDisplay.ts +37 -0
- package/src/dates/display/formatMonthForDisplay.ts +26 -0
- package/src/dates/index.ts +86 -0
- package/src/dates/internal/brand.ts +11 -0
- package/src/dates/internal/calendarHelpers.ts +18 -0
- package/src/dates/internal/clampHelpers.ts +15 -0
- package/src/dates/internal/dateIdToNativeDate.ts +15 -0
- package/src/dates/internal/intlCache.ts +40 -0
- package/src/dates/internal/intlCopy.ts +75 -0
- package/src/dates/internal/segmentBuilders.ts +94 -0
- package/src/dates/labels/dateComponentLabels.ts +79 -0
- package/src/dates/ranges/compareDateIds.ts +21 -0
- package/src/dates/ranges/compareMonthIds.ts +26 -0
- package/src/dates/ranges/dateRangeAroundDay.ts +24 -0
- package/src/dates/ranges/dateRangeFromLastNDays.ts +26 -0
- package/src/dates/ranges/eachDateIdInRange.ts +21 -0
- package/src/dates/ranges/normalizeDateRange.ts +18 -0
- package/src/dates/segments/applyDateSegmentChange.ts +57 -0
- package/src/dates/segments/formatDateSegment.ts +18 -0
- package/src/dates/segments/getDateFieldSegments.ts +45 -0
- package/src/dates/segments/getDateTimeFieldSegments.ts +126 -0
- package/src/dates/segments/getDateTimeSegmentVisibility.ts +14 -0
- package/src/dates/segments/getEmptyDateSegmentText.ts +12 -0
- package/src/dates/segments/parseDateSegment.ts +25 -0
- package/src/dates/types.ts +80 -0
- package/src/dates/wire/clampDateParts.ts +17 -0
- package/src/dates/wire/clampMonthParts.ts +15 -0
- package/src/dates/wire/dateId.ts +44 -0
- package/src/dates/wire/formatDateId.ts +20 -0
- package/src/dates/wire/formatMonthId.ts +16 -0
- package/src/dates/wire/isValidDateId.ts +22 -0
- package/src/dates/wire/isValidDateParts.ts +17 -0
- package/src/dates/wire/isValidMonthId.ts +22 -0
- package/src/dates/wire/isValidMonthParts.ts +11 -0
- package/src/dates/wire/monthId.ts +42 -0
- package/src/dates/wire/parseDateId.ts +20 -0
- package/src/dates/wire/parseMonthId.ts +20 -0
- package/src/dates/wire/toMonthId.ts +17 -0
- package/src/dates/wire/todayDateId.ts +12 -0
- package/src/dates/wire/todayMonthId.ts +12 -0
- package/src/formatNumber.ts +56 -0
- package/src/index.ts +82 -0
- package/src/types.ts +1 -0
- package/src/utils.ts +29 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { formatDayPeriodFromHour } from '../internal/intlCopy';
|
|
4
|
+
import { EMPTY_TIME_SEGMENT_TEXT, padSegment } from '../internal/segmentBuilders';
|
|
5
|
+
import { formatDateId } from '../wire/formatDateId';
|
|
6
|
+
import { isLocaleHour12 } from '../datetime/isLocaleHour12';
|
|
7
|
+
import { parseDateTimeId } from '../datetime/parseDateTimeId';
|
|
8
|
+
import { getDateFieldSegments } from './getDateFieldSegments';
|
|
9
|
+
import { getDateTimeSegmentVisibility } from './getDateTimeSegmentVisibility';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Builds ordered segments for a date-time field for the given granularity.
|
|
13
|
+
*
|
|
14
|
+
* @param value - Wire `DateTimeId`, or empty for placeholder segments.
|
|
15
|
+
* @param options - Granularity, locale, and 12/24-hour preference.
|
|
16
|
+
* @returns Ordered `DateSegment` array including date and time parts.
|
|
17
|
+
*/
|
|
18
|
+
export function getDateTimeFieldSegments(value, options) {
|
|
19
|
+
const parts = value ? parseDateTimeId(value) : null;
|
|
20
|
+
const locale = options.locale ?? 'en-US';
|
|
21
|
+
const hour12 = options.hour12 ?? isLocaleHour12(locale);
|
|
22
|
+
const segments = getDateFieldSegments(parts ? formatDateId(parts) : undefined, {
|
|
23
|
+
mode: 'date',
|
|
24
|
+
locale: options.locale
|
|
25
|
+
});
|
|
26
|
+
if (options.granularity === 'day') {
|
|
27
|
+
return segments;
|
|
28
|
+
}
|
|
29
|
+
const {
|
|
30
|
+
showMinute,
|
|
31
|
+
showSecond
|
|
32
|
+
} = getDateTimeSegmentVisibility(options.granularity);
|
|
33
|
+
if (!parts) {
|
|
34
|
+
segments.push({
|
|
35
|
+
type: 'literal',
|
|
36
|
+
text: ' ',
|
|
37
|
+
isEditable: false
|
|
38
|
+
});
|
|
39
|
+
segments.push({
|
|
40
|
+
type: 'hour',
|
|
41
|
+
text: hour12 ? EMPTY_TIME_SEGMENT_TEXT.hour : 'HH',
|
|
42
|
+
isEditable: true
|
|
43
|
+
});
|
|
44
|
+
if (showMinute) {
|
|
45
|
+
segments.push({
|
|
46
|
+
type: 'literal',
|
|
47
|
+
text: ':',
|
|
48
|
+
isEditable: false
|
|
49
|
+
});
|
|
50
|
+
segments.push({
|
|
51
|
+
type: 'minute',
|
|
52
|
+
text: EMPTY_TIME_SEGMENT_TEXT.minute,
|
|
53
|
+
isEditable: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (showSecond) {
|
|
57
|
+
segments.push({
|
|
58
|
+
type: 'literal',
|
|
59
|
+
text: ':',
|
|
60
|
+
isEditable: false
|
|
61
|
+
});
|
|
62
|
+
segments.push({
|
|
63
|
+
type: 'second',
|
|
64
|
+
text: EMPTY_TIME_SEGMENT_TEXT.second,
|
|
65
|
+
isEditable: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (hour12) {
|
|
69
|
+
segments.push({
|
|
70
|
+
type: 'literal',
|
|
71
|
+
text: ' ',
|
|
72
|
+
isEditable: false
|
|
73
|
+
});
|
|
74
|
+
segments.push({
|
|
75
|
+
type: 'dayPeriod',
|
|
76
|
+
text: EMPTY_TIME_SEGMENT_TEXT.dayPeriod,
|
|
77
|
+
isEditable: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return segments;
|
|
81
|
+
}
|
|
82
|
+
const hour = parts.hour;
|
|
83
|
+
const minute = parts.minute;
|
|
84
|
+
segments.push({
|
|
85
|
+
type: 'literal',
|
|
86
|
+
text: ' ',
|
|
87
|
+
isEditable: false
|
|
88
|
+
});
|
|
89
|
+
if (hour12) {
|
|
90
|
+
const hour12Value = hour % 12 || 12;
|
|
91
|
+
segments.push({
|
|
92
|
+
type: 'hour',
|
|
93
|
+
text: String(hour12Value),
|
|
94
|
+
value: hour12Value,
|
|
95
|
+
isEditable: true
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
segments.push({
|
|
99
|
+
type: 'hour',
|
|
100
|
+
text: padSegment('hour', hour),
|
|
101
|
+
value: hour,
|
|
102
|
+
isEditable: true
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (showMinute) {
|
|
106
|
+
segments.push({
|
|
107
|
+
type: 'literal',
|
|
108
|
+
text: ':',
|
|
109
|
+
isEditable: false
|
|
110
|
+
});
|
|
111
|
+
segments.push({
|
|
112
|
+
type: 'minute',
|
|
113
|
+
text: padSegment('minute', minute),
|
|
114
|
+
value: minute,
|
|
115
|
+
isEditable: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (showSecond) {
|
|
119
|
+
segments.push({
|
|
120
|
+
type: 'literal',
|
|
121
|
+
text: ':',
|
|
122
|
+
isEditable: false
|
|
123
|
+
});
|
|
124
|
+
segments.push({
|
|
125
|
+
type: 'second',
|
|
126
|
+
text: padSegment('second', parts.second ?? 0),
|
|
127
|
+
value: parts.second ?? 0,
|
|
128
|
+
isEditable: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (hour12) {
|
|
132
|
+
const isPm = hour >= 12;
|
|
133
|
+
segments.push({
|
|
134
|
+
type: 'literal',
|
|
135
|
+
text: ' ',
|
|
136
|
+
isEditable: false
|
|
137
|
+
});
|
|
138
|
+
segments.push({
|
|
139
|
+
type: 'dayPeriod',
|
|
140
|
+
text: formatDayPeriodFromHour(isPm ? 13 : 9, locale),
|
|
141
|
+
value: isPm ? 1 : 0,
|
|
142
|
+
isEditable: true
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return segments;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=getDateTimeFieldSegments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatDayPeriodFromHour","EMPTY_TIME_SEGMENT_TEXT","padSegment","formatDateId","isLocaleHour12","parseDateTimeId","getDateFieldSegments","getDateTimeSegmentVisibility","getDateTimeFieldSegments","value","options","parts","locale","hour12","segments","undefined","mode","granularity","showMinute","showSecond","push","type","text","isEditable","hour","minute","second","dayPeriod","hour12Value","String","isPm"],"sourceRoot":"../../../../src","sources":["dates/segments/getDateTimeFieldSegments.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Which time segments/columns are visible for a given `DateTimeGranularity`. */
|
|
4
|
+
export function getDateTimeSegmentVisibility(granularity) {
|
|
5
|
+
return {
|
|
6
|
+
showTime: granularity !== 'day',
|
|
7
|
+
showMinute: granularity === 'minute' || granularity === 'second',
|
|
8
|
+
showSecond: granularity === 'second'
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=getDateTimeSegmentVisibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getDateTimeSegmentVisibility","granularity","showTime","showMinute","showSecond"],"sourceRoot":"../../../../src","sources":["dates/segments/getDateTimeSegmentVisibility.ts"],"mappings":";;AAEA;AACA,OAAO,SAASA,4BAA4BA,CAACC,WAAgC,EAI3E;EACA,OAAO;IACLC,QAAQ,EAAED,WAAW,KAAK,KAAK;IAC/BE,UAAU,EAAEF,WAAW,KAAK,QAAQ,IAAIA,WAAW,KAAK,QAAQ;IAChEG,UAAU,EAAEH,WAAW,KAAK;EAC9B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { EMPTY_DATE_SEGMENT_TEXT } from '../internal/segmentBuilders';
|
|
4
|
+
/**
|
|
5
|
+
* Returns placeholder text for an empty editable segment (e.g. `MM`, `DD`, `YYYY`).
|
|
6
|
+
*
|
|
7
|
+
* @param type - Segment type.
|
|
8
|
+
* @returns Placeholder string, or `''` for types without a placeholder.
|
|
9
|
+
*/
|
|
10
|
+
export function getEmptyDateSegmentText(type) {
|
|
11
|
+
return EMPTY_DATE_SEGMENT_TEXT[type] ?? '';
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getEmptyDateSegmentText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EMPTY_DATE_SEGMENT_TEXT","getEmptyDateSegmentText","type"],"sourceRoot":"../../../../src","sources":["dates/segments/getEmptyDateSegmentText.ts"],"mappings":";;AAAA,SAASA,uBAAuB,QAAQ,6BAA6B;AAGrE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,IAAqB,EAAU;EACrE,OAAOF,uBAAuB,CAACE,IAAI,CAAC,IAAI,EAAE;AAC5C","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses user-entered segment text into a number, or `null` when not parseable.
|
|
5
|
+
*
|
|
6
|
+
* @param type - Segment type being edited.
|
|
7
|
+
* @param text - Raw segment text from the field.
|
|
8
|
+
* @param _options - Reserved for future locale-aware parsing.
|
|
9
|
+
* @returns Parsed number, or `null` for empty or non-numeric input.
|
|
10
|
+
*/
|
|
11
|
+
export function parseDateSegment(type, text, _options) {
|
|
12
|
+
const trimmed = text.trim();
|
|
13
|
+
if (!trimmed || type === 'literal' || type === 'dayPeriod') {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const parsed = Number(trimmed);
|
|
17
|
+
if (Number.isNaN(parsed)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=parseDateSegment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseDateSegment","type","text","_options","trimmed","trim","parsed","Number","isNaN"],"sourceRoot":"../../../../src","sources":["dates/segments/parseDateSegment.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAC9BC,IAAqB,EACrBC,IAAY,EACZC,QAA8B,EACf;EACf,MAAMC,OAAO,GAAGF,IAAI,CAACG,IAAI,CAAC,CAAC;EAC3B,IAAI,CAACD,OAAO,IAAIH,IAAI,KAAK,SAAS,IAAIA,IAAI,KAAK,WAAW,EAAE;IAC1D,OAAO,IAAI;EACb;EACA,MAAMK,MAAM,GAAGC,MAAM,CAACH,OAAO,CAAC;EAC9B,IAAIG,MAAM,CAACC,KAAK,CAACF,MAAM,CAAC,EAAE;IACxB,OAAO,IAAI;EACb;EACA,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["dates/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { clampDay, clampMonth } from '../internal/clampHelpers';
|
|
4
|
+
/**
|
|
5
|
+
* Clamps date parts so month is 1–12 and day fits the month length (no `Date` rollover).
|
|
6
|
+
*
|
|
7
|
+
* @param parts - Year, month, and day values to clamp.
|
|
8
|
+
* @returns Clamped `DateParts` with a valid calendar day for the given month.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* clampDateParts({ year: 2026, month: 2, day: 31 }) // { year: 2026, month: 2, day: 28 }
|
|
12
|
+
*/
|
|
13
|
+
export function clampDateParts(parts) {
|
|
14
|
+
const month = clampMonth(parts.month);
|
|
15
|
+
const day = clampDay(parts.year, month, parts.day);
|
|
16
|
+
return {
|
|
17
|
+
year: parts.year,
|
|
18
|
+
month,
|
|
19
|
+
day
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=clampDateParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["clampDay","clampMonth","clampDateParts","parts","month","day","year"],"sourceRoot":"../../../../src","sources":["dates/wire/clampDateParts.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,0BAA0B;AAG/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,KAAgB,EAAa;EAC1D,MAAMC,KAAK,GAAGH,UAAU,CAACE,KAAK,CAACC,KAAK,CAAC;EACrC,MAAMC,GAAG,GAAGL,QAAQ,CAACG,KAAK,CAACG,IAAI,EAAEF,KAAK,EAAED,KAAK,CAACE,GAAG,CAAC;EAClD,OAAO;IAAEC,IAAI,EAAEH,KAAK,CAACG,IAAI;IAAEF,KAAK;IAAEC;EAAI,CAAC;AACzC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { clampMonth } from '../internal/clampHelpers';
|
|
4
|
+
/**
|
|
5
|
+
* Clamps month parts so month is between 1 and 12.
|
|
6
|
+
*
|
|
7
|
+
* @param parts - Year and month values to clamp.
|
|
8
|
+
* @returns Clamped `MonthParts`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* clampMonthParts({ year: 2026, month: 13 }) // { year: 2026, month: 12 }
|
|
12
|
+
*/
|
|
13
|
+
export function clampMonthParts(parts) {
|
|
14
|
+
return {
|
|
15
|
+
year: parts.year,
|
|
16
|
+
month: clampMonth(parts.month)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=clampMonthParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["clampMonth","clampMonthParts","parts","year","month"],"sourceRoot":"../../../../src","sources":["dates/wire/clampMonthParts.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,0BAA0B;AAGrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAAiB,EAAc;EAC7D,OAAO;IAAEC,IAAI,EAAED,KAAK,CAACC,IAAI;IAAEC,KAAK,EAAEJ,UAAU,CAACE,KAAK,CAACE,KAAK;EAAE,CAAC;AAC7D","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asDateId } from '../internal/brand';
|
|
4
|
+
import { formatDateId } from './formatDateId';
|
|
5
|
+
import { isValidDateId } from './isValidDateId';
|
|
6
|
+
import { isValidDateParts } from './isValidDateParts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validating smart constructor for a wire {@link DateId} (`YYYY-MM-DD`).
|
|
10
|
+
*
|
|
11
|
+
* Accepts either a wire string or numeric parts. Throws `RangeError` on input
|
|
12
|
+
* that is not a real calendar date — use this at the boundary where you first
|
|
13
|
+
* introduce a date value so a bad id never enters your form state.
|
|
14
|
+
*
|
|
15
|
+
* @param iso - A wire date string (`YYYY-MM-DD`).
|
|
16
|
+
* @returns The branded `DateId`.
|
|
17
|
+
* @throws RangeError when the string is not a valid `DateId`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* dateId('2026-08-07'); // DateId
|
|
21
|
+
* dateId(2026, 8, 7); // DateId
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param year - Full year (e.g. `2026`).
|
|
26
|
+
* @param month - Month `1`–`12`.
|
|
27
|
+
* @param day - Day of month `1`–`31`.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export function dateId(yearOrIso, month, day) {
|
|
31
|
+
if (typeof yearOrIso === 'string') {
|
|
32
|
+
if (!isValidDateId(yearOrIso)) {
|
|
33
|
+
throw new RangeError(`Invalid DateId: "${yearOrIso}". Expected a real calendar date as "YYYY-MM-DD".`);
|
|
34
|
+
}
|
|
35
|
+
return yearOrIso;
|
|
36
|
+
}
|
|
37
|
+
const parts = {
|
|
38
|
+
year: yearOrIso,
|
|
39
|
+
month: month ?? NaN,
|
|
40
|
+
day: day ?? NaN
|
|
41
|
+
};
|
|
42
|
+
if (!isValidDateParts(parts)) {
|
|
43
|
+
throw new RangeError(`Invalid DateId parts: ${JSON.stringify(parts)}.`);
|
|
44
|
+
}
|
|
45
|
+
return asDateId(formatDateId(parts));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=dateId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asDateId","formatDateId","isValidDateId","isValidDateParts","dateId","yearOrIso","month","day","RangeError","parts","year","NaN","JSON","stringify"],"sourceRoot":"../../../../src","sources":["dates/wire/dateId.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,mBAAmB;AAE5C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,MAAMA,CAACC,SAA0B,EAAEC,KAAc,EAAEC,GAAY,EAAU;EACvF,IAAI,OAAOF,SAAS,KAAK,QAAQ,EAAE;IACjC,IAAI,CAACH,aAAa,CAACG,SAAS,CAAC,EAAE;MAC7B,MAAM,IAAIG,UAAU,CAClB,oBAAoBH,SAAS,mDAC/B,CAAC;IACH;IACA,OAAOA,SAAS;EAClB;EAEA,MAAMI,KAAK,GAAG;IAAEC,IAAI,EAAEL,SAAS;IAAEC,KAAK,EAAEA,KAAK,IAAIK,GAAG;IAAEJ,GAAG,EAAEA,GAAG,IAAII;EAAI,CAAC;EACvE,IAAI,CAACR,gBAAgB,CAACM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,UAAU,CAAC,yBAAyBI,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,GAAG,CAAC;EACzE;EACA,OAAOT,QAAQ,CAACC,YAAY,CAACQ,KAAK,CAAC,CAAC;AACtC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asDateId } from '../internal/brand';
|
|
4
|
+
import { clampDateParts } from './clampDateParts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Builds a wire `DateId`, clamping day to the month length (no `Date` rollover).
|
|
8
|
+
*
|
|
9
|
+
* @param parts - Year, month, and day values.
|
|
10
|
+
* @returns Wire `DateId` string (`YYYY-MM-DD`).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* formatDateId({ year: 2026, month: 7, day: 28 }) // '2026-07-28'
|
|
14
|
+
*/
|
|
15
|
+
export function formatDateId(parts) {
|
|
16
|
+
const clamped = clampDateParts(parts);
|
|
17
|
+
const year = String(clamped.year).padStart(4, '0');
|
|
18
|
+
const month = String(clamped.month).padStart(2, '0');
|
|
19
|
+
const day = String(clamped.day).padStart(2, '0');
|
|
20
|
+
return asDateId(`${year}-${month}-${day}`);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=formatDateId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asDateId","clampDateParts","formatDateId","parts","clamped","year","String","padStart","month","day"],"sourceRoot":"../../../../src","sources":["dates/wire/formatDateId.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,mBAAmB;AAE5C,SAASC,cAAc,QAAQ,kBAAkB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,KAAgB,EAAU;EACrD,MAAMC,OAAO,GAAGH,cAAc,CAACE,KAAK,CAAC;EACrC,MAAME,IAAI,GAAGC,MAAM,CAACF,OAAO,CAACC,IAAI,CAAC,CAACE,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAClD,MAAMC,KAAK,GAAGF,MAAM,CAACF,OAAO,CAACI,KAAK,CAAC,CAACD,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EACpD,MAAME,GAAG,GAAGH,MAAM,CAACF,OAAO,CAACK,GAAG,CAAC,CAACF,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAChD,OAAOP,QAAQ,CAAC,GAAGK,IAAI,IAAIG,KAAK,IAAIC,GAAG,EAAE,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { format } from 'date-fns';
|
|
4
|
+
import { asMonthId } from '../internal/brand';
|
|
5
|
+
/**
|
|
6
|
+
* Builds a wire `MonthId` (`YYYY-MM-01`).
|
|
7
|
+
*
|
|
8
|
+
* @param parts - Year and month values.
|
|
9
|
+
* @returns Wire `MonthId` string.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* formatMonthId({ year: 2026, month: 7 }) // '2026-07-01'
|
|
13
|
+
*/
|
|
14
|
+
export function formatMonthId(parts) {
|
|
15
|
+
return asMonthId(format(new Date(parts.year, parts.month - 1, 1), 'yyyy-MM-dd'));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=formatMonthId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["format","asMonthId","formatMonthId","parts","Date","year","month"],"sourceRoot":"../../../../src","sources":["dates/wire/formatMonthId.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,SAAS,QAAQ,mBAAmB;AAG7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,KAAiB,EAAW;EACxD,OAAOF,SAAS,CAACD,MAAM,CAAC,IAAII,IAAI,CAACD,KAAK,CAACE,IAAI,EAAEF,KAAK,CAACG,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAClF","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { format, isValid, parse } from 'date-fns';
|
|
4
|
+
const DATE_ID_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for wire `DateId` strings (`YYYY-MM-DD`).
|
|
8
|
+
*
|
|
9
|
+
* @param dateId - Candidate wire date string.
|
|
10
|
+
* @returns `true` when `dateId` is a valid `DateId`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* isValidDateId('2026-07-28') // true
|
|
14
|
+
* isValidDateId('07/28/2026') // false
|
|
15
|
+
*/
|
|
16
|
+
export function isValidDateId(dateId) {
|
|
17
|
+
if (!DATE_ID_PATTERN.test(dateId)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const parsed = parse(dateId, 'yyyy-MM-dd', new Date());
|
|
21
|
+
return isValid(parsed) && format(parsed, 'yyyy-MM-dd') === dateId;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=isValidDateId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["format","isValid","parse","DATE_ID_PATTERN","isValidDateId","dateId","test","parsed","Date"],"sourceRoot":"../../../../src","sources":["dates/wire/isValidDateId.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,OAAO,EAAEC,KAAK,QAAQ,UAAU;AAGjD,MAAMC,eAAe,GAAG,qBAAqB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,MAAc,EAAoB;EAC9D,IAAI,CAACF,eAAe,CAACG,IAAI,CAACD,MAAM,CAAC,EAAE;IACjC,OAAO,KAAK;EACd;EACA,MAAME,MAAM,GAAGL,KAAK,CAACG,MAAM,EAAE,YAAY,EAAE,IAAIG,IAAI,CAAC,CAAC,CAAC;EACtD,OAAOP,OAAO,CAACM,MAAM,CAAC,IAAIP,MAAM,CAACO,MAAM,EAAE,YAAY,CAAC,KAAKF,MAAM;AACnE","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { partsToDate } from '../internal/clampHelpers';
|
|
4
|
+
/**
|
|
5
|
+
* Returns whether the given parts form a valid calendar date.
|
|
6
|
+
*
|
|
7
|
+
* @param parts - Year, month, and day values to validate.
|
|
8
|
+
* @returns `true` when the parts match a real calendar date.
|
|
9
|
+
*/
|
|
10
|
+
export function isValidDateParts(parts) {
|
|
11
|
+
const date = partsToDate(parts);
|
|
12
|
+
return date.getFullYear() === parts.year && date.getMonth() === parts.month - 1 && date.getDate() === parts.day;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=isValidDateParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["partsToDate","isValidDateParts","parts","date","getFullYear","year","getMonth","month","getDate","day"],"sourceRoot":"../../../../src","sources":["dates/wire/isValidDateParts.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,0BAA0B;AAGtD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,KAAgB,EAAW;EAC1D,MAAMC,IAAI,GAAGH,WAAW,CAACE,KAAK,CAAC;EAC/B,OACEC,IAAI,CAACC,WAAW,CAAC,CAAC,KAAKF,KAAK,CAACG,IAAI,IACjCF,IAAI,CAACG,QAAQ,CAAC,CAAC,KAAKJ,KAAK,CAACK,KAAK,GAAG,CAAC,IACnCJ,IAAI,CAACK,OAAO,CAAC,CAAC,KAAKN,KAAK,CAACO,GAAG;AAEhC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { format, isValid, parse } from 'date-fns';
|
|
4
|
+
const MONTH_ID_PATTERN = /^\d{4}-\d{2}-01$/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for wire `MonthId` strings (`YYYY-MM-01`).
|
|
8
|
+
*
|
|
9
|
+
* @param monthId - Candidate wire month string.
|
|
10
|
+
* @returns `true` when `monthId` is a valid `MonthId`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* isValidMonthId('2026-07-01') // true
|
|
14
|
+
* isValidMonthId('2026-07-15') // false
|
|
15
|
+
*/
|
|
16
|
+
export function isValidMonthId(monthId) {
|
|
17
|
+
if (!MONTH_ID_PATTERN.test(monthId)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const parsed = parse(monthId, 'yyyy-MM-dd', new Date());
|
|
21
|
+
return isValid(parsed) && format(parsed, 'yyyy-MM-dd') === monthId;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=isValidMonthId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["format","isValid","parse","MONTH_ID_PATTERN","isValidMonthId","monthId","test","parsed","Date"],"sourceRoot":"../../../../src","sources":["dates/wire/isValidMonthId.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,OAAO,EAAEC,KAAK,QAAQ,UAAU;AAGjD,MAAMC,gBAAgB,GAAG,kBAAkB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,OAAe,EAAsB;EAClE,IAAI,CAACF,gBAAgB,CAACG,IAAI,CAACD,OAAO,CAAC,EAAE;IACnC,OAAO,KAAK;EACd;EACA,MAAME,MAAM,GAAGL,KAAK,CAACG,OAAO,EAAE,YAAY,EAAE,IAAIG,IAAI,CAAC,CAAC,CAAC;EACvD,OAAOP,OAAO,CAACM,MAAM,CAAC,IAAIP,MAAM,CAACO,MAAM,EAAE,YAAY,CAAC,KAAKF,OAAO;AACpE","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether the given parts form a valid month (1–12).
|
|
5
|
+
*
|
|
6
|
+
* @param parts - Year and month values to validate.
|
|
7
|
+
* @returns `true` when month is between 1 and 12.
|
|
8
|
+
*/
|
|
9
|
+
export function isValidMonthParts(parts) {
|
|
10
|
+
return parts.month >= 1 && parts.month <= 12;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=isValidMonthParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isValidMonthParts","parts","month"],"sourceRoot":"../../../../src","sources":["dates/wire/isValidMonthParts.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,iBAAiBA,CAACC,KAAiB,EAAW;EAC5D,OAAOA,KAAK,CAACC,KAAK,IAAI,CAAC,IAAID,KAAK,CAACC,KAAK,IAAI,EAAE;AAC9C","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asMonthId } from '../internal/brand';
|
|
4
|
+
import { formatMonthId } from './formatMonthId';
|
|
5
|
+
import { isValidMonthId } from './isValidMonthId';
|
|
6
|
+
import { isValidMonthParts } from './isValidMonthParts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validating smart constructor for a wire {@link MonthId} (`YYYY-MM-01`).
|
|
10
|
+
*
|
|
11
|
+
* Accepts either a wire string or numeric parts. Throws `RangeError` on input
|
|
12
|
+
* that is not a valid month.
|
|
13
|
+
*
|
|
14
|
+
* @param iso - A wire month string (`YYYY-MM-01`).
|
|
15
|
+
* @returns The branded `MonthId`.
|
|
16
|
+
* @throws RangeError when the string is not a valid `MonthId`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* monthId('2026-08-01'); // MonthId
|
|
20
|
+
* monthId(2026, 8); // MonthId
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param year - Full year (e.g. `2026`).
|
|
25
|
+
* @param month - Month `1`–`12`.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export function monthId(yearOrIso, month) {
|
|
29
|
+
if (typeof yearOrIso === 'string') {
|
|
30
|
+
if (!isValidMonthId(yearOrIso)) {
|
|
31
|
+
throw new RangeError(`Invalid MonthId: "${yearOrIso}". Expected the first of a month as "YYYY-MM-01".`);
|
|
32
|
+
}
|
|
33
|
+
return yearOrIso;
|
|
34
|
+
}
|
|
35
|
+
const parts = {
|
|
36
|
+
year: yearOrIso,
|
|
37
|
+
month: month ?? NaN
|
|
38
|
+
};
|
|
39
|
+
if (!isValidMonthParts(parts)) {
|
|
40
|
+
throw new RangeError(`Invalid MonthId parts: ${JSON.stringify(parts)}. Month must be 1–12.`);
|
|
41
|
+
}
|
|
42
|
+
return asMonthId(formatMonthId(parts));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=monthId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asMonthId","formatMonthId","isValidMonthId","isValidMonthParts","monthId","yearOrIso","month","RangeError","parts","year","NaN","JSON","stringify"],"sourceRoot":"../../../../src","sources":["dates/wire/monthId.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,mBAAmB;AAE7C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,iBAAiB,QAAQ,qBAAqB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,OAAOA,CAACC,SAA0B,EAAEC,KAAc,EAAW;EAC3E,IAAI,OAAOD,SAAS,KAAK,QAAQ,EAAE;IACjC,IAAI,CAACH,cAAc,CAACG,SAAS,CAAC,EAAE;MAC9B,MAAM,IAAIE,UAAU,CAClB,qBAAqBF,SAAS,mDAChC,CAAC;IACH;IACA,OAAOA,SAAS;EAClB;EAEA,MAAMG,KAAK,GAAG;IAAEC,IAAI,EAAEJ,SAAS;IAAEC,KAAK,EAAEA,KAAK,IAAII;EAAI,CAAC;EACtD,IAAI,CAACP,iBAAiB,CAACK,KAAK,CAAC,EAAE;IAC7B,MAAM,IAAID,UAAU,CAAC,0BAA0BI,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,uBAAuB,CAAC;EAC9F;EACA,OAAOR,SAAS,CAACC,aAAa,CAACO,KAAK,CAAC,CAAC;AACxC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { dateIdToNativeDate } from '../internal/dateIdToNativeDate';
|
|
4
|
+
import { isValidDateId } from './isValidDateId';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses a wire `DateId` into numeric parts, or `null` when invalid.
|
|
8
|
+
*
|
|
9
|
+
* @param dateId - Wire date string (`YYYY-MM-DD`).
|
|
10
|
+
* @returns Parsed parts, or `null` when `dateId` is invalid.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* parseDateId('2026-07-28') // { year: 2026, month: 7, day: 28 }
|
|
14
|
+
*/
|
|
15
|
+
export function parseDateId(dateId) {
|
|
16
|
+
if (!isValidDateId(dateId)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const date = dateIdToNativeDate(dateId);
|
|
20
|
+
return {
|
|
21
|
+
year: date.getFullYear(),
|
|
22
|
+
month: date.getMonth() + 1,
|
|
23
|
+
day: date.getDate()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=parseDateId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["dateIdToNativeDate","isValidDateId","parseDateId","dateId","date","year","getFullYear","month","getMonth","day","getDate"],"sourceRoot":"../../../../src","sources":["dates/wire/parseDateId.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,SAASC,aAAa,QAAQ,iBAAiB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,MAAc,EAAoB;EAC5D,IAAI,CAACF,aAAa,CAACE,MAAM,CAAC,EAAE;IAC1B,OAAO,IAAI;EACb;EACA,MAAMC,IAAI,GAAGJ,kBAAkB,CAACG,MAAM,CAAC;EACvC,OAAO;IAAEE,IAAI,EAAED,IAAI,CAACE,WAAW,CAAC,CAAC;IAAEC,KAAK,EAAEH,IAAI,CAACI,QAAQ,CAAC,CAAC,GAAG,CAAC;IAAEC,GAAG,EAAEL,IAAI,CAACM,OAAO,CAAC;EAAE,CAAC;AACtF","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { dateIdToNativeDate } from '../internal/dateIdToNativeDate';
|
|
4
|
+
import { isValidMonthId } from './isValidMonthId';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses a wire `MonthId` into numeric parts, or `null` when invalid.
|
|
8
|
+
*
|
|
9
|
+
* @param monthId - Wire month string (`YYYY-MM-01`).
|
|
10
|
+
* @returns Parsed parts, or `null` when `monthId` is invalid.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* parseMonthId('2026-07-01') // { year: 2026, month: 7 }
|
|
14
|
+
*/
|
|
15
|
+
export function parseMonthId(monthId) {
|
|
16
|
+
if (!isValidMonthId(monthId)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const date = dateIdToNativeDate(monthId);
|
|
20
|
+
return {
|
|
21
|
+
year: date.getFullYear(),
|
|
22
|
+
month: date.getMonth() + 1
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=parseMonthId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["dateIdToNativeDate","isValidMonthId","parseMonthId","monthId","date","year","getFullYear","month","getMonth"],"sourceRoot":"../../../../src","sources":["dates/wire/parseMonthId.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,SAASC,cAAc,QAAQ,kBAAkB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,OAAgB,EAAqB;EAChE,IAAI,CAACF,cAAc,CAACE,OAAO,CAAC,EAAE;IAC5B,OAAO,IAAI;EACb;EACA,MAAMC,IAAI,GAAGJ,kBAAkB,CAACG,OAAO,CAAC;EACxC,OAAO;IAAEE,IAAI,EAAED,IAAI,CAACE,WAAW,CAAC,CAAC;IAAEC,KAAK,EAAEH,IAAI,CAACI,QAAQ,CAAC,CAAC,GAAG;EAAE,CAAC;AACjE","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { format, startOfMonth } from 'date-fns';
|
|
4
|
+
import { asMonthId } from '../internal/brand';
|
|
5
|
+
import { dateIdToNativeDate } from '../internal/dateIdToNativeDate';
|
|
6
|
+
/**
|
|
7
|
+
* Truncates a `DateId` to its month wire id.
|
|
8
|
+
*
|
|
9
|
+
* @param dateId - Wire date string.
|
|
10
|
+
* @returns Wire `MonthId` for the same calendar month.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* toMonthId('2026-07-28') // '2026-07-01'
|
|
14
|
+
*/
|
|
15
|
+
export function toMonthId(dateId) {
|
|
16
|
+
return asMonthId(format(startOfMonth(dateIdToNativeDate(dateId)), 'yyyy-MM-dd'));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=toMonthId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["format","startOfMonth","asMonthId","dateIdToNativeDate","toMonthId","dateId"],"sourceRoot":"../../../../src","sources":["dates/wire/toMonthId.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,YAAY,QAAQ,UAAU;AAC/C,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,kBAAkB,QAAQ,gCAAgC;AAGnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,MAAc,EAAW;EACjD,OAAOH,SAAS,CAACF,MAAM,CAACC,YAAY,CAACE,kBAAkB,CAACE,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAClF","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { format } from 'date-fns';
|
|
4
|
+
import { asDateId } from '../internal/brand';
|
|
5
|
+
/**
|
|
6
|
+
* Returns the device-local calendar date as a wire `DateId`.
|
|
7
|
+
*
|
|
8
|
+
* @returns Today's date as `YYYY-MM-DD`.
|
|
9
|
+
*/
|
|
10
|
+
export function todayDateId() {
|
|
11
|
+
return asDateId(format(new Date(), 'yyyy-MM-dd'));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=todayDateId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["format","asDateId","todayDateId","Date"],"sourceRoot":"../../../../src","sources":["dates/wire/todayDateId.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,QAAQ,mBAAmB;AAG5C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAA,EAAW;EACpC,OAAOD,QAAQ,CAACD,MAAM,CAAC,IAAIG,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AACnD","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { format, startOfMonth } from 'date-fns';
|
|
4
|
+
import { asMonthId } from '../internal/brand';
|
|
5
|
+
/**
|
|
6
|
+
* Returns the device-local calendar month as a wire `MonthId`.
|
|
7
|
+
*
|
|
8
|
+
* @returns Current month as `YYYY-MM-01`.
|
|
9
|
+
*/
|
|
10
|
+
export function todayMonthId() {
|
|
11
|
+
return asMonthId(format(startOfMonth(new Date()), 'yyyy-MM-dd'));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=todayMonthId.js.map
|