@zag-js/date-utils 0.0.0-dev-20230601110239 → 0.0.0-dev-20230605130234
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 +4 -7
- package/dist/align.js +11 -83
- package/dist/align.mjs +24 -9
- package/dist/assertion.d.ts +10 -13
- package/dist/assertion.js +19 -48
- package/dist/assertion.mjs +36 -20
- package/dist/constrain.d.ts +6 -9
- package/dist/constrain.js +26 -52
- package/dist/constrain.mjs +58 -14
- package/dist/duration.d.ts +3 -7
- package/dist/duration.js +6 -30
- package/dist/duration.mjs +18 -8
- package/dist/format-date.d.ts +2 -5
- package/dist/format-date.js +32 -54
- package/dist/format-date.mjs +53 -6
- package/dist/format-range.d.ts +2 -5
- package/dist/format-range.js +5 -28
- package/dist/format-range.mjs +24 -6
- package/dist/format-selected-date.d.ts +2 -5
- package/dist/format-selected-date.js +10 -77
- package/dist/format-selected-date.mjs +15 -9
- package/dist/format-visible-range.d.ts +2 -5
- package/dist/format-visible-range.js +12 -68
- package/dist/format-visible-range.mjs +22 -9
- package/dist/get-day-formatter.d.ts +2 -5
- package/dist/get-day-formatter.js +9 -37
- package/dist/get-day-formatter.mjs +16 -7
- package/dist/get-decade-range.d.ts +1 -3
- package/dist/get-decade-range.js +5 -28
- package/dist/get-decade-range.mjs +11 -6
- package/dist/get-era-format.d.ts +2 -5
- package/dist/get-era-format.js +5 -28
- package/dist/get-era-format.mjs +5 -6
- package/dist/get-month-days.d.ts +3 -6
- package/dist/get-month-days.js +13 -45
- package/dist/get-month-days.mjs +24 -9
- package/dist/get-month-formatter.d.ts +2 -5
- package/dist/get-month-formatter.js +10 -38
- package/dist/get-month-formatter.mjs +15 -7
- package/dist/get-month-names.d.ts +1 -3
- package/dist/get-month-names.js +5 -28
- package/dist/get-month-names.mjs +11 -6
- package/dist/get-start-of-week.d.ts +2 -6
- package/dist/get-start-of-week.js +10 -32
- package/dist/get-start-of-week.mjs +9 -6
- package/dist/get-week-days.d.ts +3 -7
- package/dist/get-week-days.js +8 -55
- package/dist/get-week-days.mjs +11 -8
- package/dist/get-weekday-formats.d.ts +2 -5
- package/dist/get-weekday-formats.js +10 -32
- package/dist/get-weekday-formats.mjs +18 -6
- package/dist/get-year-range.d.ts +2 -4
- package/dist/get-year-range.js +5 -28
- package/dist/get-year-range.mjs +9 -6
- package/dist/index.d.ts +20 -21
- package/dist/index.js +74 -740
- package/dist/index.mjs +19 -138
- package/dist/mutation.d.ts +10 -14
- package/dist/mutation.js +17 -59
- package/dist/mutation.mjs +40 -21
- package/dist/pagination.d.ts +19 -23
- package/dist/pagination.js +35 -134
- package/dist/pagination.mjs +179 -25
- package/dist/parse-date.d.ts +2 -5
- package/dist/parse-date.js +13 -35
- package/dist/parse-date.mjs +40 -6
- package/dist/types.d.ts +8 -11
- package/package.json +2 -7
- package/dist/chunk-5HGHDJ3L.mjs +0 -14
- package/dist/chunk-6FNTXW54.mjs +0 -52
- package/dist/chunk-6LXTZHZP.mjs +0 -22
- package/dist/chunk-AMZ7CJ5F.mjs +0 -18
- package/dist/chunk-BUT5IUNZ.mjs +0 -32
- package/dist/chunk-FJKH6IJZ.mjs +0 -21
- package/dist/chunk-G4VVKINZ.mjs +0 -14
- package/dist/chunk-HKHGJ6WS.mjs +0 -27
- package/dist/chunk-HLAN6TUA.mjs +0 -45
- package/dist/chunk-KBGJA6NB.mjs +0 -55
- package/dist/chunk-KLHRN7WS.mjs +0 -20
- package/dist/chunk-KN3YMOSL.mjs +0 -8
- package/dist/chunk-KQVWH4YA.mjs +0 -29
- package/dist/chunk-LGEGBP3O.mjs +0 -20
- package/dist/chunk-MGPXEJO4.mjs +0 -71
- package/dist/chunk-NV7UFBMY.mjs +0 -30
- package/dist/chunk-POBWDZPE.mjs +0 -200
- package/dist/chunk-SI75FOJ2.mjs +0 -11
- package/dist/chunk-TTJVXKJY.mjs +0 -12
- package/dist/chunk-WQYMLJUJ.mjs +0 -42
- package/dist/chunk-ZSLC7OI2.mjs +0 -22
- package/dist/get-end-of-week.d.ts +0 -6
- package/dist/get-end-of-week.js +0 -42
- package/dist/get-end-of-week.mjs +0 -11
- package/dist/types.js +0 -18
- package/dist/types.mjs +0 -0
package/dist/chunk-TTJVXKJY.mjs
DELETED
package/dist/chunk-WQYMLJUJ.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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/chunk-ZSLC7OI2.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/duration.ts
|
|
2
|
-
function getUnitDuration(duration) {
|
|
3
|
-
let d = { ...duration };
|
|
4
|
-
for (let key in d) {
|
|
5
|
-
d[key] = 1;
|
|
6
|
-
}
|
|
7
|
-
return d;
|
|
8
|
-
}
|
|
9
|
-
function getEndDate(startDate, duration) {
|
|
10
|
-
let d = { ...duration };
|
|
11
|
-
if (d.days) {
|
|
12
|
-
d.days--;
|
|
13
|
-
} else {
|
|
14
|
-
d.days = -1;
|
|
15
|
-
}
|
|
16
|
-
return startDate.add(d);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
getUnitDuration,
|
|
21
|
-
getEndDate
|
|
22
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as _internationalized_date from '@internationalized/date';
|
|
2
|
-
import { DateValue } from '@internationalized/date';
|
|
3
|
-
|
|
4
|
-
declare function getEndOfWeek(date: DateValue, locale: string, firstDayOfWeek?: number): _internationalized_date.CalendarDate | _internationalized_date.CalendarDateTime | _internationalized_date.ZonedDateTime;
|
|
5
|
-
|
|
6
|
-
export { getEndOfWeek };
|
package/dist/get-end-of-week.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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/get-end-of-week.ts
|
|
21
|
-
var get_end_of_week_exports = {};
|
|
22
|
-
__export(get_end_of_week_exports, {
|
|
23
|
-
getEndOfWeek: () => getEndOfWeek
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(get_end_of_week_exports);
|
|
26
|
-
|
|
27
|
-
// src/get-start-of-week.ts
|
|
28
|
-
var import_date = require("@internationalized/date");
|
|
29
|
-
function getStartOfWeek(date, locale, firstDayOfWeek = 0) {
|
|
30
|
-
const day = (0, import_date.getDayOfWeek)(date, locale);
|
|
31
|
-
const diff = (day - firstDayOfWeek + 7) % 7;
|
|
32
|
-
return date.subtract({ days: diff });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/get-end-of-week.ts
|
|
36
|
-
function getEndOfWeek(date, locale, firstDayOfWeek = 0) {
|
|
37
|
-
return getStartOfWeek(date, locale, firstDayOfWeek).add({ days: 6 });
|
|
38
|
-
}
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
getEndOfWeek
|
|
42
|
-
});
|
package/dist/get-end-of-week.mjs
DELETED
package/dist/types.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
package/dist/types.mjs
DELETED
|
File without changes
|