@zag-js/date-utils 1.19.0 → 1.20.1

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/dist/index.js CHANGED
@@ -52,13 +52,14 @@ function constrainStart(date$1, aligned, duration, locale, min, max) {
52
52
  return aligned;
53
53
  }
54
54
  function constrainValue(date$1, minValue, maxValue) {
55
+ let constrainedDate = date.toCalendarDate(date$1);
55
56
  if (minValue) {
56
- date$1 = date.maxDate(date$1, date.toCalendarDate(minValue));
57
+ constrainedDate = date.maxDate(constrainedDate, date.toCalendarDate(minValue));
57
58
  }
58
59
  if (maxValue) {
59
- date$1 = date.minDate(date$1, date.toCalendarDate(maxValue));
60
+ constrainedDate = date.minDate(constrainedDate, date.toCalendarDate(maxValue));
60
61
  }
61
- return date$1;
62
+ return constrainedDate;
62
63
  }
63
64
 
64
65
  // src/align.ts
@@ -133,7 +134,7 @@ function getDayFormatter(locale, timeZone) {
133
134
  });
134
135
  }
135
136
  function getMonthFormatter(locale, timeZone) {
136
- const date$1 = date.toCalendarDate(date.today(timeZone));
137
+ const date$1 = date.today(timeZone);
137
138
  return new date.DateFormatter(locale, {
138
139
  month: "long",
139
140
  year: "numeric",
@@ -522,7 +523,7 @@ function extract(pattern, str) {
522
523
  }, {});
523
524
  }
524
525
  function getDateRangePreset(preset, locale, timeZone) {
525
- const today3 = date.now(timeZone);
526
+ const today3 = date.toCalendarDate(date.now(timeZone));
526
527
  switch (preset) {
527
528
  case "thisWeek":
528
529
  return [date.startOfWeek(today3, locale), date.endOfWeek(today3, locale)];
package/dist/index.mjs CHANGED
@@ -50,13 +50,14 @@ function constrainStart(date, aligned, duration, locale, min, max) {
50
50
  return aligned;
51
51
  }
52
52
  function constrainValue(date, minValue, maxValue) {
53
+ let constrainedDate = toCalendarDate(date);
53
54
  if (minValue) {
54
- date = maxDate(date, toCalendarDate(minValue));
55
+ constrainedDate = maxDate(constrainedDate, toCalendarDate(minValue));
55
56
  }
56
57
  if (maxValue) {
57
- date = minDate(date, toCalendarDate(maxValue));
58
+ constrainedDate = minDate(constrainedDate, toCalendarDate(maxValue));
58
59
  }
59
- return date;
60
+ return constrainedDate;
60
61
  }
61
62
 
62
63
  // src/align.ts
@@ -131,7 +132,7 @@ function getDayFormatter(locale, timeZone) {
131
132
  });
132
133
  }
133
134
  function getMonthFormatter(locale, timeZone) {
134
- const date = toCalendarDate(today(timeZone));
135
+ const date = today(timeZone);
135
136
  return new DateFormatter(locale, {
136
137
  month: "long",
137
138
  year: "numeric",
@@ -520,7 +521,7 @@ function extract(pattern, str) {
520
521
  }, {});
521
522
  }
522
523
  function getDateRangePreset(preset, locale, timeZone) {
523
- const today3 = now(timeZone);
524
+ const today3 = toCalendarDate(now(timeZone));
524
525
  switch (preset) {
525
526
  case "thisWeek":
526
527
  return [startOfWeek(today3, locale), endOfWeek(today3, locale)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/date-utils",
3
- "version": "1.19.0",
3
+ "version": "1.20.1",
4
4
  "description": "Date utilities for zag.js",
5
5
  "keywords": [
6
6
  "js",