@trackunit/date-and-time-utils 1.17.6-alpha-e1e6a0f33ce.0 → 1.17.6

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/index.cjs.js CHANGED
@@ -1745,6 +1745,25 @@ const parseValidDate = (date) => {
1745
1745
  return null;
1746
1746
  };
1747
1747
 
1748
+ const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
1749
+ /**
1750
+ * Parses a strict ISO date-only value without applying a timezone.
1751
+ *
1752
+ * @param value The date-only value in `YYYY-MM-DD` format.
1753
+ * @returns {Temporal.PlainDate | undefined} The parsed calendar date, or `undefined` when the value is invalid.
1754
+ */
1755
+ const parseCalendarDate = (value) => {
1756
+ if (!DATE_ONLY_PATTERN.test(value)) {
1757
+ return undefined;
1758
+ }
1759
+ try {
1760
+ return polyfill.Temporal.PlainDate.from(value, { overflow: "reject" });
1761
+ }
1762
+ catch {
1763
+ return undefined;
1764
+ }
1765
+ };
1766
+
1748
1767
  Object.defineProperty(exports, "Temporal", {
1749
1768
  enumerable: true,
1750
1769
  get: function () { return polyfill.Temporal; }
@@ -1793,6 +1812,7 @@ exports.isTodayUtil = isTodayUtil;
1793
1812
  exports.isValidDate = isValidDate;
1794
1813
  exports.monthNameUtil = monthNameUtil;
1795
1814
  exports.monthsUtil = monthsUtil;
1815
+ exports.parseCalendarDate = parseCalendarDate;
1796
1816
  exports.parseValidDate = parseValidDate;
1797
1817
  exports.startOfDayUtil = startOfDayUtil;
1798
1818
  exports.startOfHourUtil = startOfHourUtil;
package/index.esm.js CHANGED
@@ -1744,4 +1744,23 @@ const parseValidDate = (date) => {
1744
1744
  return null;
1745
1745
  };
1746
1746
 
1747
- export { addDaysUtil, addHoursUtil, addMinutesUtil, addMonthsUtil, addWeeksUtil, addYearsUtil, convertHoursUtil, convertMillisecondsUtil, convertMinutesUtil, convertSecondsUtil, dayNameUtil, daysUtil, differenceInDaysUtil, differenceInHoursUtil, differenceInMinutesUtil, differenceInMonthsUtil, differenceInSecondsUtil, differenceInWeeksUtil, differenceInYearsUtil, endOfDayUtil, endOfHourUtil, endOfMinuteUtil, endOfMonthUtil, endOfWeekUtil, formatDateUtil, formatRangeUtil, getDurationFormat, getHourCycle, getTimeZone, getTimeZoneOffset, getUTCFromTimeZonedUtil, getWeekUtil, isBetweenUtil, isEqualUtil, isFutureUtil, isPastUtil, isSameDayUtil, isSameMonthUtil, isSameWeekUtil, isSameYearUtil, isTodayUtil, isValidDate, monthNameUtil, monthsUtil, parseValidDate, startOfDayUtil, startOfHourUtil, startOfMinuteUtil, startOfMonthUtil, startOfWeekUtil, subtractDaysUtil, subtractHoursUtil, subtractMinutesUtil, subtractMonthsUtil, subtractWeeksUtil, subtractYearsUtil, timeFormatToHourCycle, timeSinceAuto, timeSinceInDays, timeSinceInHours, timeSinceInMinutes, timeSinceInMonths, timeSinceInSeconds, timeSinceInYears, timeZonesAvailable, toDateUtil, toDuration, toInstantUtil, toTemporalUtil, toZonedDateTimeUtil };
1747
+ const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
1748
+ /**
1749
+ * Parses a strict ISO date-only value without applying a timezone.
1750
+ *
1751
+ * @param value The date-only value in `YYYY-MM-DD` format.
1752
+ * @returns {Temporal.PlainDate | undefined} The parsed calendar date, or `undefined` when the value is invalid.
1753
+ */
1754
+ const parseCalendarDate = (value) => {
1755
+ if (!DATE_ONLY_PATTERN.test(value)) {
1756
+ return undefined;
1757
+ }
1758
+ try {
1759
+ return Temporal.PlainDate.from(value, { overflow: "reject" });
1760
+ }
1761
+ catch {
1762
+ return undefined;
1763
+ }
1764
+ };
1765
+
1766
+ export { addDaysUtil, addHoursUtil, addMinutesUtil, addMonthsUtil, addWeeksUtil, addYearsUtil, convertHoursUtil, convertMillisecondsUtil, convertMinutesUtil, convertSecondsUtil, dayNameUtil, daysUtil, differenceInDaysUtil, differenceInHoursUtil, differenceInMinutesUtil, differenceInMonthsUtil, differenceInSecondsUtil, differenceInWeeksUtil, differenceInYearsUtil, endOfDayUtil, endOfHourUtil, endOfMinuteUtil, endOfMonthUtil, endOfWeekUtil, formatDateUtil, formatRangeUtil, getDurationFormat, getHourCycle, getTimeZone, getTimeZoneOffset, getUTCFromTimeZonedUtil, getWeekUtil, isBetweenUtil, isEqualUtil, isFutureUtil, isPastUtil, isSameDayUtil, isSameMonthUtil, isSameWeekUtil, isSameYearUtil, isTodayUtil, isValidDate, monthNameUtil, monthsUtil, parseCalendarDate, parseValidDate, startOfDayUtil, startOfHourUtil, startOfMinuteUtil, startOfMonthUtil, startOfWeekUtil, subtractDaysUtil, subtractHoursUtil, subtractMinutesUtil, subtractMonthsUtil, subtractWeeksUtil, subtractYearsUtil, timeFormatToHourCycle, timeSinceAuto, timeSinceInDays, timeSinceInHours, timeSinceInMinutes, timeSinceInMonths, timeSinceInSeconds, timeSinceInYears, timeZonesAvailable, toDateUtil, toDuration, toInstantUtil, toTemporalUtil, toZonedDateTimeUtil };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/date-and-time-utils",
3
- "version": "1.17.6-alpha-e1e6a0f33ce.0",
3
+ "version": "1.17.6",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
package/src/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./DateAndTimeUtils";
2
+ export * from "./parseCalendarDate";
2
3
  export { Temporal } from "./temporal";
@@ -0,0 +1,8 @@
1
+ import { Temporal } from "./temporal";
2
+ /**
3
+ * Parses a strict ISO date-only value without applying a timezone.
4
+ *
5
+ * @param value The date-only value in `YYYY-MM-DD` format.
6
+ * @returns {Temporal.PlainDate | undefined} The parsed calendar date, or `undefined` when the value is invalid.
7
+ */
8
+ export declare const parseCalendarDate: (value: string) => Temporal.PlainDate | undefined;
@@ -1 +0,0 @@
1
- {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/date-and-time/utils/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}