@zag-js/date-utils 1.47.0 → 1.48.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.mts +4 -8
- package/dist/align.d.ts +4 -8
- package/dist/align.js +15 -47
- package/dist/align.mjs +10 -21
- package/dist/assertion.d.mts +6 -10
- package/dist/assertion.d.ts +6 -10
- package/dist/assertion.js +21 -48
- package/dist/assertion.mjs +13 -19
- package/dist/constrain.d.mts +7 -10
- package/dist/constrain.d.ts +7 -10
- package/dist/constrain.js +68 -133
- package/dist/constrain.mjs +59 -110
- package/dist/date-month.d.mts +17 -21
- package/dist/date-month.d.ts +17 -21
- package/dist/date-month.js +103 -112
- package/dist/date-month.mjs +92 -86
- package/dist/date-year.d.mts +8 -11
- package/dist/date-year.d.ts +8 -11
- package/dist/date-year.js +35 -62
- package/dist/date-year.mjs +28 -34
- package/dist/duration.d.mts +8 -12
- package/dist/duration.d.ts +8 -12
- package/dist/duration.js +13 -37
- package/dist/duration.mjs +8 -11
- package/dist/format.d.mts +5 -8
- package/dist/format.d.ts +5 -8
- package/dist/format.js +35 -76
- package/dist/format.mjs +29 -49
- package/dist/formatter.d.mts +3 -6
- package/dist/formatter.d.ts +3 -6
- package/dist/formatter.js +26 -50
- package/dist/formatter.mjs +21 -24
- package/dist/get-era-format.d.mts +2 -6
- package/dist/get-era-format.d.ts +2 -6
- package/dist/get-era-format.js +9 -34
- package/dist/get-era-format.mjs +5 -9
- package/dist/index.d.mts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +66 -47
- package/dist/index.mjs +14 -14
- package/dist/locale.d.mts +3 -5
- package/dist/locale.d.ts +3 -5
- package/dist/locale.js +28 -55
- package/dist/locale.mjs +22 -28
- package/dist/mutation.d.mts +6 -10
- package/dist/mutation.d.ts +6 -10
- package/dist/mutation.js +21 -53
- package/dist/mutation.mjs +14 -30
- package/dist/pagination.d.mts +16 -19
- package/dist/pagination.d.ts +16 -19
- package/dist/pagination.js +120 -201
- package/dist/pagination.mjs +106 -166
- package/dist/parse-date.d.mts +2 -6
- package/dist/parse-date.d.ts +2 -6
- package/dist/parse-date.js +41 -72
- package/dist/parse-date.mjs +37 -47
- package/dist/preset.d.mts +3 -6
- package/dist/preset.d.ts +3 -6
- package/dist/preset.js +23 -63
- package/dist/preset.mjs +19 -47
- package/dist/types.d.mts +17 -20
- package/dist/types.d.ts +17 -20
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/package.json +3 -3
package/dist/date-month.mjs
CHANGED
|
@@ -1,105 +1,111 @@
|
|
|
1
|
+
import { DateFormatter, endOfWeek, getWeeksInMonth, isSameDay, startOfWeek } from "@internationalized/date";
|
|
1
2
|
// src/date-month.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const daysOfTheWeek = [
|
|
4
|
+
"sun",
|
|
5
|
+
"mon",
|
|
6
|
+
"tue",
|
|
7
|
+
"wed",
|
|
8
|
+
"thu",
|
|
9
|
+
"fri",
|
|
10
|
+
"sat"
|
|
11
|
+
];
|
|
10
12
|
function normalizeFirstDayOfWeek(firstDayOfWeek) {
|
|
11
|
-
|
|
13
|
+
return firstDayOfWeek != null ? daysOfTheWeek[firstDayOfWeek] : void 0;
|
|
12
14
|
}
|
|
13
15
|
function getStartOfWeek(date, locale, firstDayOfWeek) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const firstDay = normalizeFirstDayOfWeek(firstDayOfWeek);
|
|
17
|
+
return startOfWeek(date, locale, firstDay);
|
|
16
18
|
}
|
|
17
19
|
function getEndOfWeek(date, locale, firstDayOfWeek = 0) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const firstDay = normalizeFirstDayOfWeek(firstDayOfWeek);
|
|
21
|
+
return endOfWeek(date, locale, firstDay);
|
|
20
22
|
}
|
|
21
23
|
function getDaysInWeek(weekIndex, from, locale, firstDayOfWeek) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
const weekDate = from.add({ weeks: weekIndex });
|
|
25
|
+
const dates = [];
|
|
26
|
+
let date = getStartOfWeek(weekDate, locale, firstDayOfWeek);
|
|
27
|
+
while (dates.length < 7) {
|
|
28
|
+
dates.push(date);
|
|
29
|
+
let nextDate = date.add({ days: 1 });
|
|
30
|
+
if (isSameDay(date, nextDate)) break;
|
|
31
|
+
date = nextDate;
|
|
32
|
+
}
|
|
33
|
+
return dates;
|
|
32
34
|
}
|
|
33
35
|
function getMonthDays(from, locale, numOfWeeks, firstDayOfWeek) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return weeks.map((week) => getDaysInWeek(week, from, locale, firstDayOfWeek));
|
|
36
|
+
const firstDay = normalizeFirstDayOfWeek(firstDayOfWeek);
|
|
37
|
+
const monthWeeks = numOfWeeks ?? getWeeksInMonth(from, locale, firstDay);
|
|
38
|
+
return [...new Array(monthWeeks).keys()].map((week) => getDaysInWeek(week, from, locale, firstDayOfWeek));
|
|
38
39
|
}
|
|
39
40
|
function getWeekdayFormats(locale, timeZone) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
const longFormat = new DateFormatter(locale, {
|
|
42
|
+
weekday: "long",
|
|
43
|
+
timeZone
|
|
44
|
+
});
|
|
45
|
+
const shortFormat = new DateFormatter(locale, {
|
|
46
|
+
weekday: "short",
|
|
47
|
+
timeZone
|
|
48
|
+
});
|
|
49
|
+
const narrowFormat = new DateFormatter(locale, {
|
|
50
|
+
weekday: "narrow",
|
|
51
|
+
timeZone
|
|
52
|
+
});
|
|
53
|
+
return (value) => {
|
|
54
|
+
const date = value instanceof Date ? value : value.toDate(timeZone);
|
|
55
|
+
return {
|
|
56
|
+
value,
|
|
57
|
+
short: shortFormat.format(date),
|
|
58
|
+
long: longFormat.format(date),
|
|
59
|
+
narrow: narrowFormat.format(date)
|
|
60
|
+
};
|
|
61
|
+
};
|
|
52
62
|
}
|
|
53
63
|
function getWeekDays(date, startOfWeekProp, timeZone, locale) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
const firstDayOfWeek = getStartOfWeek(date, locale, startOfWeekProp);
|
|
65
|
+
const weeks = [...new Array(7).keys()];
|
|
66
|
+
const format = getWeekdayFormats(locale, timeZone);
|
|
67
|
+
return weeks.map((index) => format(firstDayOfWeek.add({ days: index })));
|
|
58
68
|
}
|
|
59
69
|
function getMonthNames(locale, format = "long", referenceDate) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
if (!referenceDate || referenceDate.calendar.identifier === "gregory" || referenceDate.calendar.identifier === "iso8601") {
|
|
71
|
+
const date = new Date(2021, 0, 1);
|
|
72
|
+
const monthNames = [];
|
|
73
|
+
for (let i = 0; i < 12; i++) {
|
|
74
|
+
monthNames.push(date.toLocaleString(locale, { month: format }));
|
|
75
|
+
date.setMonth(date.getMonth() + 1);
|
|
76
|
+
}
|
|
77
|
+
return monthNames;
|
|
78
|
+
}
|
|
79
|
+
const monthCount = referenceDate.calendar.getMonthsInYear(referenceDate);
|
|
80
|
+
const formatter = new DateFormatter(locale, {
|
|
81
|
+
month: format,
|
|
82
|
+
calendar: referenceDate.calendar.identifier
|
|
83
|
+
});
|
|
84
|
+
const monthNames = [];
|
|
85
|
+
for (let month = 1; month <= monthCount; month++) {
|
|
86
|
+
const d = referenceDate.set({ month });
|
|
87
|
+
monthNames.push(formatter.format(d.toDate("UTC")));
|
|
88
|
+
}
|
|
89
|
+
return monthNames;
|
|
80
90
|
}
|
|
81
91
|
function getWeekOfYear(date, locale) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const mondayOfWeek = startOfWeek(date, locale, "mon");
|
|
93
|
+
const year = mondayOfWeek.year;
|
|
94
|
+
const jan4 = mondayOfWeek.set({
|
|
95
|
+
month: 1,
|
|
96
|
+
day: 4
|
|
97
|
+
});
|
|
98
|
+
const week1Monday = startOfWeek(jan4, locale, "mon");
|
|
99
|
+
const julianMonday = mondayOfWeek.calendar.toJulianDay(mondayOfWeek);
|
|
100
|
+
const julianWeek1 = week1Monday.calendar.toJulianDay(week1Monday);
|
|
101
|
+
if (julianMonday >= julianWeek1) return 1 + Math.floor((julianMonday - julianWeek1) / 7);
|
|
102
|
+
const prevJan4 = mondayOfWeek.set({
|
|
103
|
+
year: year - 1,
|
|
104
|
+
month: 1,
|
|
105
|
+
day: 4
|
|
106
|
+
});
|
|
107
|
+
const prevWeek1Monday = startOfWeek(prevJan4, locale, "mon");
|
|
108
|
+
const julianPrevWeek1 = prevWeek1Monday.calendar.toJulianDay(prevWeek1Monday);
|
|
109
|
+
return 1 + Math.floor((julianMonday - julianPrevWeek1) / 7);
|
|
95
110
|
}
|
|
96
|
-
export {
|
|
97
|
-
getDaysInWeek,
|
|
98
|
-
getEndOfWeek,
|
|
99
|
-
getMonthDays,
|
|
100
|
-
getMonthNames,
|
|
101
|
-
getStartOfWeek,
|
|
102
|
-
getWeekDays,
|
|
103
|
-
getWeekOfYear,
|
|
104
|
-
getWeekdayFormats
|
|
105
|
-
};
|
|
111
|
+
export { getDaysInWeek, getEndOfWeek, getMonthDays, getMonthNames, getStartOfWeek, getWeekDays, getWeekOfYear, getWeekdayFormats };
|
package/dist/date-year.d.mts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { DateValue } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
to: number;
|
|
1
|
+
import { DateValue } from "@internationalized/date";
|
|
2
|
+
export interface YearsRange {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number;
|
|
6
5
|
}
|
|
7
|
-
declare function getYearsRange(range: YearsRange): number[];
|
|
8
|
-
declare function getDefaultYearRange(referenceDate: DateValue, min?: DateValue, max?: DateValue): YearsRange;
|
|
9
|
-
declare function normalizeYear(year: string | null | undefined): string | undefined;
|
|
10
|
-
declare function getDecadeRange(year: number): number[];
|
|
11
|
-
|
|
12
|
-
export { type YearsRange, getDecadeRange, getDefaultYearRange, getYearsRange, normalizeYear };
|
|
6
|
+
export declare function getYearsRange(range: YearsRange): number[];
|
|
7
|
+
export declare function getDefaultYearRange(referenceDate: DateValue, min?: DateValue, max?: DateValue): YearsRange;
|
|
8
|
+
export declare function normalizeYear(year: string | null | undefined): string | undefined;
|
|
9
|
+
export declare function getDecadeRange(year: number): number[];
|
package/dist/date-year.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { DateValue } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
to: number;
|
|
1
|
+
import { DateValue } from "@internationalized/date";
|
|
2
|
+
export interface YearsRange {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number;
|
|
6
5
|
}
|
|
7
|
-
declare function getYearsRange(range: YearsRange): number[];
|
|
8
|
-
declare function getDefaultYearRange(referenceDate: DateValue, min?: DateValue, max?: DateValue): YearsRange;
|
|
9
|
-
declare function normalizeYear(year: string | null | undefined): string | undefined;
|
|
10
|
-
declare function getDecadeRange(year: number): number[];
|
|
11
|
-
|
|
12
|
-
export { type YearsRange, getDecadeRange, getDefaultYearRange, getYearsRange, normalizeYear };
|
|
6
|
+
export declare function getYearsRange(range: YearsRange): number[];
|
|
7
|
+
export declare function getDefaultYearRange(referenceDate: DateValue, min?: DateValue, max?: DateValue): YearsRange;
|
|
8
|
+
export declare function normalizeYear(year: string | null | undefined): string | undefined;
|
|
9
|
+
export declare function getDecadeRange(year: number): number[];
|
package/dist/date-year.js
CHANGED
|
@@ -1,71 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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/date-year.ts
|
|
21
|
-
var date_year_exports = {};
|
|
22
|
-
__export(date_year_exports, {
|
|
23
|
-
getDecadeRange: () => getDecadeRange,
|
|
24
|
-
getDefaultYearRange: () => getDefaultYearRange,
|
|
25
|
-
getYearsRange: () => getYearsRange,
|
|
26
|
-
normalizeYear: () => normalizeYear
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
27
4
|
});
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
let _internationalized_date = require("@internationalized/date");
|
|
6
|
+
// src/date-year.ts
|
|
30
7
|
function getYearsRange(range) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
const years = [];
|
|
9
|
+
for (let year = range.from; year <= range.to; year += 1) years.push(year);
|
|
10
|
+
return years;
|
|
34
11
|
}
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
const DEFAULT_MIN_YEAR = 1900;
|
|
13
|
+
const DEFAULT_MAX_YEAR = 2099;
|
|
37
14
|
function getDefaultYearRange(referenceDate, min, max) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
const calendar = referenceDate.calendar;
|
|
16
|
+
return {
|
|
17
|
+
from: min?.year ?? (0, _internationalized_date.toCalendar)(new _internationalized_date.CalendarDate(DEFAULT_MIN_YEAR, 1, 1), calendar).year,
|
|
18
|
+
to: max?.year ?? (0, _internationalized_date.toCalendar)(new _internationalized_date.CalendarDate(DEFAULT_MAX_YEAR, 12, 31), calendar).year
|
|
19
|
+
};
|
|
42
20
|
}
|
|
43
|
-
|
|
21
|
+
const FUTURE_YEAR_COERCION = 10;
|
|
44
22
|
function normalizeYear(year) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return year;
|
|
23
|
+
if (!year) return;
|
|
24
|
+
if (year.length === 3) return year.padEnd(4, "0");
|
|
25
|
+
if (year.length === 2) {
|
|
26
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
27
|
+
const fullYear = Math.floor(currentYear / 100) * 100 + parseInt(year.slice(-2), 10);
|
|
28
|
+
return fullYear > currentYear + FUTURE_YEAR_COERCION ? (fullYear - 100).toString() : fullYear.toString();
|
|
29
|
+
}
|
|
30
|
+
return year;
|
|
55
31
|
}
|
|
56
32
|
function getDecadeRange(year) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
33
|
+
const computedYear = year - year % 10;
|
|
34
|
+
const years = [];
|
|
35
|
+
for (let i = 0; i < 10; i += 1) {
|
|
36
|
+
const value = computedYear + i;
|
|
37
|
+
years.push(value);
|
|
38
|
+
}
|
|
39
|
+
return years;
|
|
64
40
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
getYearsRange,
|
|
70
|
-
normalizeYear
|
|
71
|
-
});
|
|
41
|
+
exports.getDecadeRange = getDecadeRange;
|
|
42
|
+
exports.getDefaultYearRange = getDefaultYearRange;
|
|
43
|
+
exports.getYearsRange = getYearsRange;
|
|
44
|
+
exports.normalizeYear = normalizeYear;
|
package/dist/date-year.mjs
CHANGED
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
// src/date-year.ts
|
|
2
1
|
import { CalendarDate, toCalendar } from "@internationalized/date";
|
|
2
|
+
// src/date-year.ts
|
|
3
3
|
function getYearsRange(range) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const years = [];
|
|
5
|
+
for (let year = range.from; year <= range.to; year += 1) years.push(year);
|
|
6
|
+
return years;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const DEFAULT_MIN_YEAR = 1900;
|
|
9
|
+
const DEFAULT_MAX_YEAR = 2099;
|
|
10
10
|
function getDefaultYearRange(referenceDate, min, max) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const calendar = referenceDate.calendar;
|
|
12
|
+
return {
|
|
13
|
+
from: min?.year ?? toCalendar(new CalendarDate(DEFAULT_MIN_YEAR, 1, 1), calendar).year,
|
|
14
|
+
to: max?.year ?? toCalendar(new CalendarDate(DEFAULT_MAX_YEAR, 12, 31), calendar).year
|
|
15
|
+
};
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
const FUTURE_YEAR_COERCION = 10;
|
|
17
18
|
function normalizeYear(year) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
return year;
|
|
19
|
+
if (!year) return;
|
|
20
|
+
if (year.length === 3) return year.padEnd(4, "0");
|
|
21
|
+
if (year.length === 2) {
|
|
22
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
23
|
+
const fullYear = Math.floor(currentYear / 100) * 100 + parseInt(year.slice(-2), 10);
|
|
24
|
+
return fullYear > currentYear + FUTURE_YEAR_COERCION ? (fullYear - 100).toString() : fullYear.toString();
|
|
25
|
+
}
|
|
26
|
+
return year;
|
|
28
27
|
}
|
|
29
28
|
function getDecadeRange(year) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const computedYear = year - year % 10;
|
|
30
|
+
const years = [];
|
|
31
|
+
for (let i = 0; i < 10; i += 1) {
|
|
32
|
+
const value = computedYear + i;
|
|
33
|
+
years.push(value);
|
|
34
|
+
}
|
|
35
|
+
return years;
|
|
37
36
|
}
|
|
38
|
-
export {
|
|
39
|
-
getDecadeRange,
|
|
40
|
-
getDefaultYearRange,
|
|
41
|
-
getYearsRange,
|
|
42
|
-
normalizeYear
|
|
43
|
-
};
|
|
37
|
+
export { getDecadeRange, getDefaultYearRange, getYearsRange, normalizeYear };
|
package/dist/duration.d.mts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DateDuration } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
weeks?: number;
|
|
9
|
-
days?: number;
|
|
1
|
+
import { DateValue as DateValue$1 } from "./types.mjs";
|
|
2
|
+
import { DateDuration } from "@internationalized/date";
|
|
3
|
+
export declare function getUnitDuration(duration: DateDuration): {
|
|
4
|
+
years?: number;
|
|
5
|
+
months?: number;
|
|
6
|
+
weeks?: number;
|
|
7
|
+
days?: number;
|
|
10
8
|
};
|
|
11
|
-
declare function getEndDate(startDate: DateValue, duration: DateDuration):
|
|
12
|
-
|
|
13
|
-
export { getEndDate, getUnitDuration };
|
|
9
|
+
export declare function getEndDate(startDate: DateValue$1, duration: DateDuration): import("@internationalized/date").CalendarDate | import("@internationalized/date").CalendarDateTime | import("@internationalized/date").ZonedDateTime;
|
package/dist/duration.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DateDuration } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
weeks?: number;
|
|
9
|
-
days?: number;
|
|
1
|
+
import { DateValue as DateValue$1 } from "./types.js";
|
|
2
|
+
import { DateDuration } from "@internationalized/date";
|
|
3
|
+
export declare function getUnitDuration(duration: DateDuration): {
|
|
4
|
+
years?: number;
|
|
5
|
+
months?: number;
|
|
6
|
+
weeks?: number;
|
|
7
|
+
days?: number;
|
|
10
8
|
};
|
|
11
|
-
declare function getEndDate(startDate: DateValue, duration: DateDuration):
|
|
12
|
-
|
|
13
|
-
export { getEndDate, getUnitDuration };
|
|
9
|
+
export declare function getEndDate(startDate: DateValue$1, duration: DateDuration): import("@internationalized/date").CalendarDate | import("@internationalized/date").CalendarDateTime | import("@internationalized/date").ZonedDateTime;
|
package/dist/duration.js
CHANGED
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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/duration.ts
|
|
21
|
-
var duration_exports = {};
|
|
22
|
-
__export(duration_exports, {
|
|
23
|
-
getEndDate: () => getEndDate,
|
|
24
|
-
getUnitDuration: () => getUnitDuration
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
5
|
+
// src/duration.ts
|
|
27
6
|
function getUnitDuration(duration) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
let clone = { ...duration };
|
|
8
|
+
for (let key in clone) clone[key] = 1;
|
|
9
|
+
return clone;
|
|
31
10
|
}
|
|
32
11
|
function getEndDate(startDate, duration) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
let clone = { ...duration };
|
|
13
|
+
if (clone.days) clone.days--;
|
|
14
|
+
else clone.days = -1;
|
|
15
|
+
return startDate.add(clone);
|
|
37
16
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
getEndDate,
|
|
41
|
-
getUnitDuration
|
|
42
|
-
});
|
|
17
|
+
exports.getEndDate = getEndDate;
|
|
18
|
+
exports.getUnitDuration = getUnitDuration;
|
package/dist/duration.mjs
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
// src/duration.ts
|
|
2
2
|
function getUnitDuration(duration) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
let clone = { ...duration };
|
|
4
|
+
for (let key in clone) clone[key] = 1;
|
|
5
|
+
return clone;
|
|
6
6
|
}
|
|
7
7
|
function getEndDate(startDate, duration) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
let clone = { ...duration };
|
|
9
|
+
if (clone.days) clone.days--;
|
|
10
|
+
else clone.days = -1;
|
|
11
|
+
return startDate.add(clone);
|
|
12
12
|
}
|
|
13
|
-
export {
|
|
14
|
-
getEndDate,
|
|
15
|
-
getUnitDuration
|
|
16
|
-
};
|
|
13
|
+
export { getEndDate, getUnitDuration };
|
package/dist/format.d.mts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare function
|
|
5
|
-
declare function
|
|
6
|
-
declare function formatVisibleRange(startDate: DateValue, endDate: DateValue | null, locale: string, timeZone: string): string;
|
|
7
|
-
|
|
8
|
-
export { formatRange, formatSelectedDate, formatVisibleRange };
|
|
1
|
+
import { DateValue as DateValue$1 } from "./types.mjs";
|
|
2
|
+
import { DateFormatter } from "@internationalized/date";
|
|
3
|
+
export declare function formatRange(startDate: DateValue$1, endDate: DateValue$1, formatter: DateFormatter, toString: (start: string, end: string) => string, timeZone: string): string;
|
|
4
|
+
export declare function formatSelectedDate(startDate: DateValue$1 | null | undefined, endDate: DateValue$1 | null, locale: string, timeZone: string): string;
|
|
5
|
+
export declare function formatVisibleRange(startDate: DateValue$1, endDate: DateValue$1 | null, locale: string, timeZone: string): string;
|
package/dist/format.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare function
|
|
5
|
-
declare function
|
|
6
|
-
declare function formatVisibleRange(startDate: DateValue, endDate: DateValue | null, locale: string, timeZone: string): string;
|
|
7
|
-
|
|
8
|
-
export { formatRange, formatSelectedDate, formatVisibleRange };
|
|
1
|
+
import { DateValue as DateValue$1 } from "./types.js";
|
|
2
|
+
import { DateFormatter } from "@internationalized/date";
|
|
3
|
+
export declare function formatRange(startDate: DateValue$1, endDate: DateValue$1, formatter: DateFormatter, toString: (start: string, end: string) => string, timeZone: string): string;
|
|
4
|
+
export declare function formatSelectedDate(startDate: DateValue$1 | null | undefined, endDate: DateValue$1 | null, locale: string, timeZone: string): string;
|
|
5
|
+
export declare function formatVisibleRange(startDate: DateValue$1, endDate: DateValue$1 | null, locale: string, timeZone: string): string;
|