@zag-js/date-utils 0.1.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/align.d.ts +3 -3
- package/dist/assertion.d.ts +7 -7
- package/dist/assertion.js +2 -2
- package/dist/assertion.mjs +1 -1
- package/dist/{chunk-ZZPZ2BFS.mjs → chunk-6FNTXW54.mjs} +8 -8
- package/dist/{chunk-LQAXQPWP.mjs → chunk-6LXTZHZP.mjs} +1 -1
- package/dist/{chunk-ODG5YF5H.mjs → chunk-FJKH6IJZ.mjs} +2 -2
- package/dist/{chunk-H4CAPQVS.mjs → chunk-HLAN6TUA.mjs} +2 -2
- package/dist/chunk-KBGJA6NB.mjs +55 -0
- package/dist/{chunk-CAYCTIEJ.mjs → chunk-KQVWH4YA.mjs} +1 -1
- package/dist/{chunk-KFJ757ZA.mjs → chunk-NV7UFBMY.mjs} +1 -3
- package/dist/{chunk-VTFZA34K.mjs → chunk-POBWDZPE.mjs} +2 -1
- package/dist/chunk-WQYMLJUJ.mjs +42 -0
- package/dist/constrain.d.ts +6 -6
- package/dist/duration.d.ts +3 -2
- package/dist/format-date.d.ts +9 -0
- package/dist/format-date.js +79 -0
- package/dist/format-date.mjs +6 -0
- package/dist/format-range.d.ts +2 -2
- package/dist/format-selected-date.d.ts +2 -2
- package/dist/format-selected-date.js +1 -1
- package/dist/format-selected-date.mjs +2 -2
- package/dist/format-visible-range.d.ts +2 -2
- package/dist/format-visible-range.js +1 -1
- package/dist/format-visible-range.mjs +2 -2
- package/dist/get-day-formatter.js +1 -1
- package/dist/get-day-formatter.mjs +1 -1
- package/dist/get-end-of-week.d.ts +3 -2
- package/dist/get-era-format.d.ts +2 -2
- package/dist/get-month-days.d.ts +3 -3
- package/dist/get-month-days.js +1 -3
- package/dist/get-month-days.mjs +1 -1
- package/dist/get-start-of-week.d.ts +3 -2
- package/dist/get-week-days.d.ts +4 -3
- package/dist/get-weekday-formats.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +105 -27
- package/dist/index.mjs +14 -10
- package/dist/mutation.d.ts +10 -9
- package/dist/mutation.js +7 -7
- package/dist/mutation.mjs +1 -1
- package/dist/pagination.d.ts +40 -39
- package/dist/pagination.js +1 -0
- package/dist/pagination.mjs +2 -2
- package/dist/parse-date.d.ts +5 -0
- package/dist/parse-date.js +66 -0
- package/dist/{conversion.mjs → parse-date.mjs} +1 -1
- package/dist/types.d.ts +7 -7
- package/package.json +1 -1
- package/dist/chunk-UHOBXAHP.mjs +0 -17
- package/dist/conversion.d.ts +0 -5
- package/dist/conversion.js +0 -41
package/dist/align.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue, DateDuration } from '@internationalized/date';
|
|
2
2
|
import { DateAlignment } from './types.js';
|
|
3
3
|
|
|
4
|
-
declare function alignDate(date:
|
|
5
|
-
declare function alignStartDate(date:
|
|
4
|
+
declare function alignDate(date: DateValue, alignment: DateAlignment, duration: DateDuration, locale: string, min?: DateValue | undefined, max?: DateValue | undefined): DateValue;
|
|
5
|
+
declare function alignStartDate(date: DateValue, startDate: DateValue, endDate: DateValue, duration: DateDuration, locale: string, min?: DateValue | undefined, max?: DateValue | undefined): DateValue;
|
|
6
6
|
|
|
7
7
|
export { alignDate, alignStartDate };
|
package/dist/assertion.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
2
|
import { DateAvailableFn } from './types.js';
|
|
3
3
|
|
|
4
|
-
declare function isTodayDate(date:
|
|
5
|
-
declare function isDateEqual(dateA:
|
|
4
|
+
declare function isTodayDate(date: DateValue, timeZone: string): boolean;
|
|
5
|
+
declare function isDateEqual(dateA: DateValue, dateB?: DateValue | null): boolean;
|
|
6
6
|
declare function isDateInvalid(date: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
7
7
|
declare function isDateDisabled(date: DateValue, startDate: DateValue, endDate: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
8
|
-
declare function isDateUnavailable(date: DateValue | null, isUnavailable: DateAvailableFn | undefined, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
9
|
-
declare function isDateOutsideVisibleRange(date:
|
|
10
|
-
declare function isPreviousVisibleRangeInvalid(startDate:
|
|
11
|
-
declare function isNextVisibleRangeInvalid(endDate:
|
|
8
|
+
declare function isDateUnavailable(date: DateValue | null, isUnavailable: DateAvailableFn | undefined, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
9
|
+
declare function isDateOutsideVisibleRange(date: DateValue, startDate: DateValue, endDate: DateValue): boolean;
|
|
10
|
+
declare function isPreviousVisibleRangeInvalid(startDate: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
11
|
+
declare function isNextVisibleRangeInvalid(endDate: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
12
12
|
|
|
13
13
|
export { isDateDisabled, isDateEqual, isDateInvalid, isDateOutsideVisibleRange, isDateUnavailable, isNextVisibleRangeInvalid, isPreviousVisibleRangeInvalid, isTodayDate };
|
package/dist/assertion.js
CHANGED
|
@@ -43,11 +43,11 @@ function isDateInvalid(date, minValue, maxValue) {
|
|
|
43
43
|
function isDateDisabled(date, startDate, endDate, minValue, maxValue) {
|
|
44
44
|
return date.compare(startDate) < 0 || date.compare(endDate) > 0 || isDateInvalid(date, minValue, maxValue);
|
|
45
45
|
}
|
|
46
|
-
function isDateUnavailable(date, isUnavailable, minValue, maxValue) {
|
|
46
|
+
function isDateUnavailable(date, isUnavailable, locale, minValue, maxValue) {
|
|
47
47
|
if (!date) {
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
|
-
if (isUnavailable?.(date)) {
|
|
50
|
+
if (isUnavailable?.(date, locale)) {
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
53
|
return isDateInvalid(date, minValue, maxValue);
|
package/dist/assertion.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-MGPXEJO4.mjs";
|
|
4
4
|
|
|
5
5
|
// src/mutation.ts
|
|
6
|
-
import { toCalendar,
|
|
7
|
-
function getTodayDate(
|
|
8
|
-
return today(
|
|
6
|
+
import { getLocalTimeZone, toCalendar, toCalendarDateTime, today } from "@internationalized/date";
|
|
7
|
+
function getTodayDate(timeZone) {
|
|
8
|
+
return today(timeZone ?? getLocalTimeZone());
|
|
9
9
|
}
|
|
10
10
|
function getNextDay(date) {
|
|
11
11
|
return date.add({ days: 1 });
|
|
@@ -20,19 +20,19 @@ function setYear(date, year) {
|
|
|
20
20
|
return date.set({ year });
|
|
21
21
|
}
|
|
22
22
|
function setCalendar(date, calendar) {
|
|
23
|
-
return toCalendar(
|
|
23
|
+
return toCalendar(toCalendarDateTime(date), calendar);
|
|
24
24
|
}
|
|
25
|
-
function setDate(date, startDate, isDateUnavailable, minValue, maxValue) {
|
|
25
|
+
function setDate(date, startDate, isDateUnavailable, locale, minValue, maxValue) {
|
|
26
26
|
let result;
|
|
27
27
|
result = constrainValue(date, minValue, maxValue);
|
|
28
|
-
result = getPreviousAvailableDate(date, startDate, isDateUnavailable);
|
|
28
|
+
result = getPreviousAvailableDate(date, startDate, locale, isDateUnavailable);
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
-
function getPreviousAvailableDate(date, minValue, isDateUnavailable) {
|
|
31
|
+
function getPreviousAvailableDate(date, minValue, locale, isDateUnavailable) {
|
|
32
32
|
if (!isDateUnavailable) {
|
|
33
33
|
return date;
|
|
34
34
|
}
|
|
35
|
-
while (date.compare(minValue) >= 0 && isDateUnavailable(date)) {
|
|
35
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(date, locale)) {
|
|
36
36
|
date = date.subtract({ days: 1 });
|
|
37
37
|
}
|
|
38
38
|
if (date.compare(minValue) >= 0) {
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-KN3YMOSL.mjs";
|
|
4
4
|
|
|
5
5
|
// src/get-day-formatter.ts
|
|
6
|
-
import { DateFormatter,
|
|
6
|
+
import { DateFormatter, toCalendarDateTime, today } from "@internationalized/date";
|
|
7
7
|
function getDayFormatter(locale, timeZone) {
|
|
8
|
-
const date =
|
|
8
|
+
const date = toCalendarDateTime(today(timeZone));
|
|
9
9
|
return new DateFormatter(locale, {
|
|
10
10
|
weekday: "long",
|
|
11
11
|
month: "long",
|
|
@@ -12,11 +12,11 @@ function isDateInvalid(date, minValue, maxValue) {
|
|
|
12
12
|
function isDateDisabled(date, startDate, endDate, minValue, maxValue) {
|
|
13
13
|
return date.compare(startDate) < 0 || date.compare(endDate) > 0 || isDateInvalid(date, minValue, maxValue);
|
|
14
14
|
}
|
|
15
|
-
function isDateUnavailable(date, isUnavailable, minValue, maxValue) {
|
|
15
|
+
function isDateUnavailable(date, isUnavailable, locale, minValue, maxValue) {
|
|
16
16
|
if (!date) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
if (isUnavailable?.(date)) {
|
|
19
|
+
if (isUnavailable?.(date, locale)) {
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
return isDateInvalid(date, minValue, maxValue);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/format-date.ts
|
|
2
|
+
import { toCalendarDateTime } from "@internationalized/date";
|
|
3
|
+
function createRegEx(sign) {
|
|
4
|
+
let symbols = "\\s|\\.|-|/|\\\\|,|\\$|\\!|\\?|:|;";
|
|
5
|
+
return new RegExp("(^|>|" + symbols + ")(" + sign + ")($|<|" + symbols + ")", "g");
|
|
6
|
+
}
|
|
7
|
+
function formatDate(value, formatString, locale, timeZone = "UTC") {
|
|
8
|
+
const datetime = toCalendarDateTime(value);
|
|
9
|
+
const date = datetime.toDate(timeZone);
|
|
10
|
+
const formats = {
|
|
11
|
+
// Time in ms
|
|
12
|
+
T: date.getTime(),
|
|
13
|
+
// Minutes
|
|
14
|
+
m: date.toLocaleString(locale, { minute: "numeric" }),
|
|
15
|
+
mm: date.toLocaleString(locale, { minute: "2-digit" }),
|
|
16
|
+
// Seconds
|
|
17
|
+
s: date.toLocaleString(locale, { second: "numeric" }),
|
|
18
|
+
ss: date.toLocaleString(locale, { second: "2-digit" }),
|
|
19
|
+
// Hours
|
|
20
|
+
h: date.toLocaleString(locale, { hour: "numeric", hour12: true }),
|
|
21
|
+
hh: date.toLocaleString(locale, { hour: "2-digit", hour12: true }),
|
|
22
|
+
H: date.toLocaleString(locale, { hour: "numeric", hour12: false }),
|
|
23
|
+
HH: date.toLocaleString(locale, { hour: "2-digit", hour12: false }),
|
|
24
|
+
// Day period
|
|
25
|
+
aa: date.toLocaleString(locale, { hour: "numeric", hour12: true }).toLowerCase(),
|
|
26
|
+
AA: date.toLocaleString(locale, { hour: "numeric", hour12: true }).toUpperCase(),
|
|
27
|
+
// Day of week
|
|
28
|
+
E: date.toLocaleString(locale, { weekday: "short" }),
|
|
29
|
+
EE: date.toLocaleString(locale, { weekday: "short" }),
|
|
30
|
+
EEE: date.toLocaleString(locale, { weekday: "short" }),
|
|
31
|
+
EEEE: date.toLocaleString(locale, { weekday: "long" }),
|
|
32
|
+
// Date of month
|
|
33
|
+
d: datetime.day,
|
|
34
|
+
dd: date.toLocaleString(locale, { day: "2-digit" }),
|
|
35
|
+
// Months
|
|
36
|
+
M: datetime.month + 1,
|
|
37
|
+
MM: date.toLocaleString(locale, { month: "2-digit" }),
|
|
38
|
+
MMM: date.toLocaleString(locale, { month: "short" }),
|
|
39
|
+
MMMM: date.toLocaleString(locale, { month: "long" }),
|
|
40
|
+
// Years
|
|
41
|
+
yy: date.toLocaleString(locale, { year: "2-digit" }),
|
|
42
|
+
yyyy: date.toLocaleString(locale, { year: "numeric" }),
|
|
43
|
+
YY: date.toLocaleString(locale, { year: "2-digit" }),
|
|
44
|
+
YYYY: date.toLocaleString(locale, { year: "numeric" })
|
|
45
|
+
};
|
|
46
|
+
let result = formatString;
|
|
47
|
+
for (const key in formats) {
|
|
48
|
+
result = result.replace(createRegEx(key), "$1" + formats[key] + "$3");
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
formatDate
|
|
55
|
+
};
|
|
@@ -21,9 +21,7 @@ function getDaysInWeek(weekIndex, from, locale, firstDayOfWeek) {
|
|
|
21
21
|
function getMonthDays(from, locale, numOfWeeks, firstDayOfWeek) {
|
|
22
22
|
const monthWeeks = getWeeksInMonth(from, locale);
|
|
23
23
|
const weeks = [...new Array(numOfWeeks ?? monthWeeks).keys()];
|
|
24
|
-
return weeks.map((week) =>
|
|
25
|
-
return getDaysInWeek(week, from, locale, firstDayOfWeek);
|
|
26
|
-
});
|
|
24
|
+
return weeks.map((week) => getDaysInWeek(week, from, locale, firstDayOfWeek));
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isDateInvalid
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HLAN6TUA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
alignEnd,
|
|
6
6
|
alignStart,
|
|
@@ -126,6 +126,7 @@ function getSectionEnd(focusedDate, startDate, visibleDuration, locale, minValue
|
|
|
126
126
|
}
|
|
127
127
|
if (visibleDuration.weeks) {
|
|
128
128
|
return adjust({
|
|
129
|
+
//@ts-expect-error - endOfWeek is loosely typed
|
|
129
130
|
focusedDate: endOfWeek(focusedDate, locale),
|
|
130
131
|
startDate
|
|
131
132
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/parse-date.ts
|
|
2
|
+
import { CalendarDateTime, DateFormatter } from "@internationalized/date";
|
|
3
|
+
function parseDateString(date, locale, timeZone) {
|
|
4
|
+
const regex = createRegex(locale, timeZone);
|
|
5
|
+
const { year, month, day } = extract(regex, date) ?? {};
|
|
6
|
+
if (year != null && year.length === 4 && month != null && +month <= 12 && day != null && +day <= 31) {
|
|
7
|
+
return new CalendarDateTime(+year, +month, +day);
|
|
8
|
+
}
|
|
9
|
+
const time = Date.parse(date);
|
|
10
|
+
if (!isNaN(time)) {
|
|
11
|
+
const date2 = new Date(time);
|
|
12
|
+
return new CalendarDateTime(date2.getFullYear(), date2.getMonth() + 1, date2.getDate());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function createRegex(locale, timeZone) {
|
|
16
|
+
const formatter = new DateFormatter(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone });
|
|
17
|
+
const parts = formatter.formatToParts(new Date(2e3, 11, 25));
|
|
18
|
+
return parts.map(({ type, value }) => type === "literal" ? value : `((?!=<${type}>)\\d+)`).join("");
|
|
19
|
+
}
|
|
20
|
+
function extract(pattern, str) {
|
|
21
|
+
const matches = str.match(pattern);
|
|
22
|
+
return pattern.toString().match(/<(.+?)>/g)?.map((group) => {
|
|
23
|
+
const groupMatches = group.match(/<(.+)>/);
|
|
24
|
+
if (!groupMatches || groupMatches.length <= 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return group.match(/<(.+)>/)?.[1];
|
|
28
|
+
}).reduce((acc, curr, index) => {
|
|
29
|
+
if (!curr)
|
|
30
|
+
return acc;
|
|
31
|
+
if (matches && matches.length > index) {
|
|
32
|
+
acc[curr] = matches[index + 1];
|
|
33
|
+
} else {
|
|
34
|
+
acc[curr] = null;
|
|
35
|
+
}
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
parseDateString
|
|
42
|
+
};
|
package/dist/constrain.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue, DateDuration } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function alignCenter(date:
|
|
4
|
-
declare function alignStart(date:
|
|
5
|
-
declare function alignEnd(date:
|
|
6
|
-
declare function constrainStart(date:
|
|
7
|
-
declare function constrainValue(date:
|
|
3
|
+
declare function alignCenter(date: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
4
|
+
declare function alignStart(date: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
5
|
+
declare function alignEnd(date: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
6
|
+
declare function constrainStart(date: DateValue, aligned: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
7
|
+
declare function constrainValue(date: DateValue, minValue?: DateValue, maxValue?: DateValue): DateValue;
|
|
8
8
|
|
|
9
9
|
export { alignCenter, alignEnd, alignStart, constrainStart, constrainValue };
|
package/dist/duration.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
+
import { DateDuration, DateValue } from '@internationalized/date';
|
|
2
3
|
|
|
3
4
|
declare function getUnitDuration(duration: DateDuration): {
|
|
4
5
|
years?: number | undefined;
|
|
@@ -6,6 +7,6 @@ declare function getUnitDuration(duration: DateDuration): {
|
|
|
6
7
|
weeks?: number | undefined;
|
|
7
8
|
days?: number | undefined;
|
|
8
9
|
};
|
|
9
|
-
declare function getEndDate(startDate:
|
|
10
|
+
declare function getEndDate(startDate: DateValue, duration: DateDuration): _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime;
|
|
10
11
|
|
|
11
12
|
export { getEndDate, getUnitDuration };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formats a date using the given format string as defined in:
|
|
5
|
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
6
|
+
*/
|
|
7
|
+
declare function formatDate(value: DateValue, formatString: string, locale: string, timeZone?: string): string;
|
|
8
|
+
|
|
9
|
+
export { formatDate };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/format-date.ts
|
|
21
|
+
var format_date_exports = {};
|
|
22
|
+
__export(format_date_exports, {
|
|
23
|
+
formatDate: () => formatDate
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(format_date_exports);
|
|
26
|
+
var import_date = require("@internationalized/date");
|
|
27
|
+
function createRegEx(sign) {
|
|
28
|
+
let symbols = "\\s|\\.|-|/|\\\\|,|\\$|\\!|\\?|:|;";
|
|
29
|
+
return new RegExp("(^|>|" + symbols + ")(" + sign + ")($|<|" + symbols + ")", "g");
|
|
30
|
+
}
|
|
31
|
+
function formatDate(value, formatString, locale, timeZone = "UTC") {
|
|
32
|
+
const datetime = (0, import_date.toCalendarDateTime)(value);
|
|
33
|
+
const date = datetime.toDate(timeZone);
|
|
34
|
+
const formats = {
|
|
35
|
+
// Time in ms
|
|
36
|
+
T: date.getTime(),
|
|
37
|
+
// Minutes
|
|
38
|
+
m: date.toLocaleString(locale, { minute: "numeric" }),
|
|
39
|
+
mm: date.toLocaleString(locale, { minute: "2-digit" }),
|
|
40
|
+
// Seconds
|
|
41
|
+
s: date.toLocaleString(locale, { second: "numeric" }),
|
|
42
|
+
ss: date.toLocaleString(locale, { second: "2-digit" }),
|
|
43
|
+
// Hours
|
|
44
|
+
h: date.toLocaleString(locale, { hour: "numeric", hour12: true }),
|
|
45
|
+
hh: date.toLocaleString(locale, { hour: "2-digit", hour12: true }),
|
|
46
|
+
H: date.toLocaleString(locale, { hour: "numeric", hour12: false }),
|
|
47
|
+
HH: date.toLocaleString(locale, { hour: "2-digit", hour12: false }),
|
|
48
|
+
// Day period
|
|
49
|
+
aa: date.toLocaleString(locale, { hour: "numeric", hour12: true }).toLowerCase(),
|
|
50
|
+
AA: date.toLocaleString(locale, { hour: "numeric", hour12: true }).toUpperCase(),
|
|
51
|
+
// Day of week
|
|
52
|
+
E: date.toLocaleString(locale, { weekday: "short" }),
|
|
53
|
+
EE: date.toLocaleString(locale, { weekday: "short" }),
|
|
54
|
+
EEE: date.toLocaleString(locale, { weekday: "short" }),
|
|
55
|
+
EEEE: date.toLocaleString(locale, { weekday: "long" }),
|
|
56
|
+
// Date of month
|
|
57
|
+
d: datetime.day,
|
|
58
|
+
dd: date.toLocaleString(locale, { day: "2-digit" }),
|
|
59
|
+
// Months
|
|
60
|
+
M: datetime.month + 1,
|
|
61
|
+
MM: date.toLocaleString(locale, { month: "2-digit" }),
|
|
62
|
+
MMM: date.toLocaleString(locale, { month: "short" }),
|
|
63
|
+
MMMM: date.toLocaleString(locale, { month: "long" }),
|
|
64
|
+
// Years
|
|
65
|
+
yy: date.toLocaleString(locale, { year: "2-digit" }),
|
|
66
|
+
yyyy: date.toLocaleString(locale, { year: "numeric" }),
|
|
67
|
+
YY: date.toLocaleString(locale, { year: "2-digit" }),
|
|
68
|
+
YYYY: date.toLocaleString(locale, { year: "numeric" })
|
|
69
|
+
};
|
|
70
|
+
let result = formatString;
|
|
71
|
+
for (const key in formats) {
|
|
72
|
+
result = result.replace(createRegEx(key), "$1" + formats[key] + "$3");
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
formatDate
|
|
79
|
+
});
|
package/dist/format-range.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue, DateFormatter } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function formatRange(startDate:
|
|
3
|
+
declare function formatRange(startDate: DateValue, endDate: DateValue, formatter: DateFormatter, toString: (start: string, end: string) => string, timeZone: string): string;
|
|
4
4
|
|
|
5
5
|
export { formatRange };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function formatSelectedDate(startDate:
|
|
3
|
+
declare function formatSelectedDate(startDate: DateValue, endDate: DateValue | null, locale: string, timeZone: string): string;
|
|
4
4
|
|
|
5
5
|
export { formatSelectedDate };
|
|
@@ -59,7 +59,7 @@ function getEraFormat(date) {
|
|
|
59
59
|
|
|
60
60
|
// src/get-day-formatter.ts
|
|
61
61
|
function getDayFormatter(locale, timeZone) {
|
|
62
|
-
const date = (0, import_date.
|
|
62
|
+
const date = (0, import_date.toCalendarDateTime)((0, import_date.today)(timeZone));
|
|
63
63
|
return new import_date.DateFormatter(locale, {
|
|
64
64
|
weekday: "long",
|
|
65
65
|
month: "long",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function formatVisibleRange(startDate:
|
|
3
|
+
declare function formatVisibleRange(startDate: DateValue, endDate: DateValue | null, locale: string, timeZone: string): string;
|
|
4
4
|
|
|
5
5
|
export { formatVisibleRange };
|
|
@@ -35,7 +35,7 @@ function getEraFormat(date) {
|
|
|
35
35
|
|
|
36
36
|
// src/get-day-formatter.ts
|
|
37
37
|
function getDayFormatter(locale, timeZone) {
|
|
38
|
-
const date = (0, import_date.
|
|
38
|
+
const date = (0, import_date.toCalendarDateTime)((0, import_date.today)(timeZone));
|
|
39
39
|
return new import_date.DateFormatter(locale, {
|
|
40
40
|
weekday: "long",
|
|
41
41
|
month: "long",
|
|
@@ -32,7 +32,7 @@ function getEraFormat(date) {
|
|
|
32
32
|
|
|
33
33
|
// src/get-day-formatter.ts
|
|
34
34
|
function getDayFormatter(locale, timeZone) {
|
|
35
|
-
const date = (0, import_date.
|
|
35
|
+
const date = (0, import_date.toCalendarDateTime)((0, import_date.today)(timeZone));
|
|
36
36
|
return new import_date.DateFormatter(locale, {
|
|
37
37
|
weekday: "long",
|
|
38
38
|
month: "long",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
+
import { DateValue } from '@internationalized/date';
|
|
2
3
|
|
|
3
|
-
declare function getEndOfWeek(date:
|
|
4
|
+
declare function getEndOfWeek(date: DateValue, locale: string, firstDayOfWeek?: number): _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime;
|
|
4
5
|
|
|
5
6
|
export { getEndOfWeek };
|
package/dist/get-era-format.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function getEraFormat(date:
|
|
3
|
+
declare function getEraFormat(date: DateValue | undefined): "short" | undefined;
|
|
4
4
|
|
|
5
5
|
export { getEraFormat };
|
package/dist/get-month-days.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function getDaysInWeek(weekIndex: number, from:
|
|
4
|
-
declare function getMonthDays(from:
|
|
3
|
+
declare function getDaysInWeek(weekIndex: number, from: DateValue, locale: string, firstDayOfWeek?: number): (DateValue | null)[];
|
|
4
|
+
declare function getMonthDays(from: DateValue, locale: string, numOfWeeks?: number, firstDayOfWeek?: number): (DateValue | null)[][];
|
|
5
5
|
|
|
6
6
|
export { getDaysInWeek, getMonthDays };
|
package/dist/get-month-days.js
CHANGED
|
@@ -52,9 +52,7 @@ function getDaysInWeek(weekIndex, from, locale, firstDayOfWeek) {
|
|
|
52
52
|
function getMonthDays(from, locale, numOfWeeks, firstDayOfWeek) {
|
|
53
53
|
const monthWeeks = (0, import_date2.getWeeksInMonth)(from, locale);
|
|
54
54
|
const weeks = [...new Array(numOfWeeks ?? monthWeeks).keys()];
|
|
55
|
-
return weeks.map((week) =>
|
|
56
|
-
return getDaysInWeek(week, from, locale, firstDayOfWeek);
|
|
57
|
-
});
|
|
55
|
+
return weeks.map((week) => getDaysInWeek(week, from, locale, firstDayOfWeek));
|
|
58
56
|
}
|
|
59
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
58
|
0 && (module.exports = {
|
package/dist/get-month-days.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
+
import { DateValue } from '@internationalized/date';
|
|
2
3
|
|
|
3
|
-
declare function getStartOfWeek(date:
|
|
4
|
+
declare function getStartOfWeek(date: DateValue, locale: string, firstDayOfWeek?: number): _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime;
|
|
4
5
|
|
|
5
6
|
export { getStartOfWeek };
|
package/dist/get-week-days.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
+
import { DateValue } from '@internationalized/date';
|
|
2
3
|
|
|
3
|
-
declare function getWeekDays(date:
|
|
4
|
-
value: CalendarDate;
|
|
4
|
+
declare function getWeekDays(date: DateValue, startOfWeekProp: number | undefined, timeZone: string, locale: string): {
|
|
5
|
+
value: _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime;
|
|
5
6
|
short: string;
|
|
6
7
|
long: string;
|
|
7
8
|
narrow: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
2
|
|
|
3
|
-
declare function getWeekdayFormats(locale: string, timeZone: string): <T extends
|
|
3
|
+
declare function getWeekdayFormats(locale: string, timeZone: string): <T extends DateValue | Date>(value: T) => {
|
|
4
4
|
value: T;
|
|
5
5
|
short: string;
|
|
6
6
|
long: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { alignDate, alignStartDate } from './align.js';
|
|
2
2
|
export { isDateDisabled, isDateEqual, isDateInvalid, isDateOutsideVisibleRange, isDateUnavailable, isNextVisibleRangeInvalid, isPreviousVisibleRangeInvalid, isTodayDate } from './assertion.js';
|
|
3
3
|
export { alignCenter, alignEnd, alignStart, constrainStart, constrainValue } from './constrain.js';
|
|
4
|
-
export { parseDateString } from './conversion.js';
|
|
5
4
|
export { getEndDate, getUnitDuration } from './duration.js';
|
|
5
|
+
export { formatDate } from './format-date.js';
|
|
6
6
|
export { formatRange } from './format-range.js';
|
|
7
7
|
export { formatSelectedDate } from './format-selected-date.js';
|
|
8
8
|
export { formatVisibleRange } from './format-visible-range.js';
|
|
@@ -16,5 +16,6 @@ export { getWeekdayFormats } from './get-weekday-formats.js';
|
|
|
16
16
|
export { YearsRange, getYearsRange } from './get-year-range.js';
|
|
17
17
|
export { getNextDay, getPreviousAvailableDate, getPreviousDay, getTodayDate, setCalendar, setDate, setMonth, setYear } from './mutation.js';
|
|
18
18
|
export { getAdjustedDateFn, getNextPage, getNextRow, getNextSection, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart } from './pagination.js';
|
|
19
|
+
export { parseDateString } from './parse-date.js';
|
|
19
20
|
export { DateAdjustFn, DateGranularity } from './types.js';
|
|
20
21
|
import '@internationalized/date';
|