temporal-fmt 0.9.71 → 0.9.80
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/README.md +13 -49
- package/dist/{chunk-MXXTJ5CW.js → chunk-5KP5H7X2.js} +3 -3
- package/dist/{chunk-ZT3UXRAA.js → chunk-DMJWJTFY.js} +3 -8
- package/dist/chunk-DMJWJTFY.js.map +1 -0
- package/dist/{chunk-CQJYB7E7.js → chunk-HGRT37LT.js} +4 -10
- package/dist/chunk-HGRT37LT.js.map +1 -0
- package/dist/{chunk-3FMUGYE2.js → chunk-KV6GMX4D.js} +4 -159
- package/dist/chunk-KV6GMX4D.js.map +1 -0
- package/dist/chunk-UGYSEYUQ.js +168 -0
- package/dist/chunk-UGYSEYUQ.js.map +1 -0
- package/dist/{chunk-3SC5AVSY.js → chunk-WEVNKOQA.js} +2 -2
- package/dist/chunk-WP7TBCTT.js +241 -0
- package/dist/chunk-WP7TBCTT.js.map +1 -0
- package/dist/{chunk-BQET6RUR.js → chunk-Z245NHDT.js} +2 -19
- package/dist/{chunk-BQET6RUR.js.map → chunk-Z245NHDT.js.map} +1 -1
- package/dist/format.cjs +0 -17
- package/dist/format.cjs.map +1 -1
- package/dist/format.js +3 -3
- package/dist/index.cjs +3832 -4705
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -103
- package/dist/index.d.ts +20 -103
- package/dist/index.js +2406 -846
- package/dist/index.js.map +1 -1
- package/dist/interval.cjs +106 -4773
- package/dist/interval.cjs.map +1 -1
- package/dist/interval.js +5 -10
- package/dist/parse.cjs +0 -13
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.js +3 -3
- package/dist/recurrence.js +2 -1
- package/dist/relativeTime.cjs.map +1 -1
- package/dist/relativeTime.js +2 -2
- package/dist/tokens.d.cts +0 -4
- package/dist/tokens.d.ts +0 -4
- package/package.json +5 -21
- package/MODS.md +0 -148
- package/dist/chunk-3FMUGYE2.js.map +0 -1
- package/dist/chunk-CQJYB7E7.js.map +0 -1
- package/dist/chunk-ZT3UXRAA.js.map +0 -1
- package/dist/chunk-ZTIF4ZHX.js +0 -3041
- package/dist/chunk-ZTIF4ZHX.js.map +0 -1
- package/dist/modApi.d.cts +0 -147
- package/dist/modApi.d.ts +0 -147
- package/dist/runtime.d.cts +0 -206
- package/dist/runtime.d.ts +0 -206
- package/scripts/cli.mjs +0 -324
- package/scripts/loadMods.d.mts +0 -37
- package/scripts/loadMods.mjs +0 -801
- package/scripts/managePermissions.mjs +0 -126
- package/scripts/modConfig.mjs +0 -96
- package/scripts/modSandbox.d.mts +0 -13
- package/scripts/modSandbox.mjs +0 -855
- package/scripts/modWire.mjs +0 -241
- package/scripts/modWorker.mjs +0 -574
- package/scripts/semverRange.mjs +0 -157
- package/scripts/versions.json +0 -42
- /package/dist/{chunk-MXXTJ5CW.js.map → chunk-5KP5H7X2.js.map} +0 -0
- /package/dist/{chunk-3SC5AVSY.js.map → chunk-WEVNKOQA.js.map} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asDateFieldView
|
|
3
|
+
} from "./chunk-KEPIXQK7.js";
|
|
4
|
+
import {
|
|
5
|
+
dayOfWeekFromCivil,
|
|
6
|
+
daysFromCivil
|
|
7
|
+
} from "./chunk-BLZDBPSV.js";
|
|
8
|
+
|
|
9
|
+
// src/comparison.ts
|
|
10
|
+
function toComparableMs(view) {
|
|
11
|
+
const days = daysFromCivil(view.year, view.month, view.day);
|
|
12
|
+
const MS_PER_HOUR = 36e5;
|
|
13
|
+
const MS_PER_MINUTE = 6e4;
|
|
14
|
+
const MS_PER_SECOND = 1e3;
|
|
15
|
+
return days * 864e5 + (view.hour ?? 0) * MS_PER_HOUR + (view.minute ?? 0) * MS_PER_MINUTE + (view.second ?? 0) * MS_PER_SECOND + (view.millisecond ?? 0);
|
|
16
|
+
}
|
|
17
|
+
function asDateTimeFieldView(value) {
|
|
18
|
+
const v = asDateFieldView(value);
|
|
19
|
+
return v;
|
|
20
|
+
}
|
|
21
|
+
function compare(a, b) {
|
|
22
|
+
const av = asDateTimeFieldView(a);
|
|
23
|
+
const bv = asDateTimeFieldView(b);
|
|
24
|
+
const am = toComparableMs(av);
|
|
25
|
+
const bm = toComparableMs(bv);
|
|
26
|
+
if (am < bm) return -1;
|
|
27
|
+
if (am > bm) return 1;
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
function isEqual(a, b) {
|
|
31
|
+
return compare(a, b) === 0;
|
|
32
|
+
}
|
|
33
|
+
function isBefore(a, b) {
|
|
34
|
+
return compare(a, b) < 0;
|
|
35
|
+
}
|
|
36
|
+
function isAfter(a, b) {
|
|
37
|
+
return compare(a, b) > 0;
|
|
38
|
+
}
|
|
39
|
+
function min(values) {
|
|
40
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
41
|
+
throw new Error("temporal-fmt: min() requires a non-empty array of values.");
|
|
42
|
+
}
|
|
43
|
+
let best = values[0];
|
|
44
|
+
for (let i = 1; i < values.length; i++) {
|
|
45
|
+
if (compare(values[i], best) < 0) best = values[i];
|
|
46
|
+
}
|
|
47
|
+
return best;
|
|
48
|
+
}
|
|
49
|
+
function max(values) {
|
|
50
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
51
|
+
throw new Error("temporal-fmt: max() requires a non-empty array of values.");
|
|
52
|
+
}
|
|
53
|
+
let best = values[0];
|
|
54
|
+
for (let i = 1; i < values.length; i++) {
|
|
55
|
+
if (compare(values[i], best) > 0) best = values[i];
|
|
56
|
+
}
|
|
57
|
+
return best;
|
|
58
|
+
}
|
|
59
|
+
function clamp(value, lo, hi) {
|
|
60
|
+
if (compare(value, lo) < 0) return lo;
|
|
61
|
+
if (compare(value, hi) > 0) return hi;
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function isBetween(value, lo, hi) {
|
|
65
|
+
return compare(value, lo) >= 0 && compare(value, hi) <= 0;
|
|
66
|
+
}
|
|
67
|
+
function readYearMonthDay(value) {
|
|
68
|
+
const v = asDateFieldView(value);
|
|
69
|
+
return { year: v.year, month: v.month, day: v.day };
|
|
70
|
+
}
|
|
71
|
+
function todayYearMonthDay() {
|
|
72
|
+
const now = /* @__PURE__ */ new Date();
|
|
73
|
+
return { year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate() };
|
|
74
|
+
}
|
|
75
|
+
function dateEqualYearMonthDay(a, b) {
|
|
76
|
+
return a.year === b.year && a.month === b.month && a.day === b.day;
|
|
77
|
+
}
|
|
78
|
+
function isSameDay(value, reference) {
|
|
79
|
+
return dateEqualYearMonthDay(readYearMonthDay(value), readYearMonthDay(reference));
|
|
80
|
+
}
|
|
81
|
+
function isToday(value) {
|
|
82
|
+
return dateEqualYearMonthDay(readYearMonthDay(value), todayYearMonthDay());
|
|
83
|
+
}
|
|
84
|
+
function tomorrowYearMonthDay() {
|
|
85
|
+
const d = /* @__PURE__ */ new Date();
|
|
86
|
+
d.setDate(d.getDate() + 1);
|
|
87
|
+
return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };
|
|
88
|
+
}
|
|
89
|
+
function yesterdayYearMonthDay() {
|
|
90
|
+
const d = /* @__PURE__ */ new Date();
|
|
91
|
+
d.setDate(d.getDate() - 1);
|
|
92
|
+
return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };
|
|
93
|
+
}
|
|
94
|
+
function isTomorrow(value) {
|
|
95
|
+
return dateEqualYearMonthDay(readYearMonthDay(value), tomorrowYearMonthDay());
|
|
96
|
+
}
|
|
97
|
+
function isYesterday(value) {
|
|
98
|
+
return dateEqualYearMonthDay(readYearMonthDay(value), yesterdayYearMonthDay());
|
|
99
|
+
}
|
|
100
|
+
function sameWeek(yearA, monthA, dayA, yearB, monthB, dayB) {
|
|
101
|
+
const daysSince = (y, m, d) => {
|
|
102
|
+
return daysFromCivil(y, m, d);
|
|
103
|
+
};
|
|
104
|
+
const a = daysSince(yearA, monthA, dayA);
|
|
105
|
+
const b = daysSince(yearB, monthB, dayB);
|
|
106
|
+
if (Math.abs(a - b) >= 7) return false;
|
|
107
|
+
const weekdayOf = (y, m, d) => {
|
|
108
|
+
return dayOfWeekFromCivil(y, m, d);
|
|
109
|
+
};
|
|
110
|
+
const wa = a - (weekdayOf(yearA, monthA, dayA) - 1);
|
|
111
|
+
const wb = b - (weekdayOf(yearB, monthB, dayB) - 1);
|
|
112
|
+
return wa === wb;
|
|
113
|
+
}
|
|
114
|
+
function isSameWeek(value, reference) {
|
|
115
|
+
const a = readYearMonthDay(value);
|
|
116
|
+
const b = readYearMonthDay(reference);
|
|
117
|
+
return sameWeek(a.year, a.month, a.day, b.year, b.month, b.day);
|
|
118
|
+
}
|
|
119
|
+
function isSameMonth(value, reference) {
|
|
120
|
+
const a = readYearMonthDay(value);
|
|
121
|
+
const b = readYearMonthDay(reference);
|
|
122
|
+
return a.year === b.year && a.month === b.month;
|
|
123
|
+
}
|
|
124
|
+
function isSameQuarter(value, reference) {
|
|
125
|
+
const a = readYearMonthDay(value);
|
|
126
|
+
const b = readYearMonthDay(reference);
|
|
127
|
+
return a.year === b.year && Math.ceil(a.month / 3) === Math.ceil(b.month / 3);
|
|
128
|
+
}
|
|
129
|
+
function isSameYear(value, reference) {
|
|
130
|
+
return readYearMonthDay(value).year === readYearMonthDay(reference).year;
|
|
131
|
+
}
|
|
132
|
+
function isWeekend(value) {
|
|
133
|
+
if (typeof value !== "object" || value === null) {
|
|
134
|
+
throw new Error(`temporal-fmt: isWeekend() expected a Temporal value, got ${String(value)}.`);
|
|
135
|
+
}
|
|
136
|
+
const v = value;
|
|
137
|
+
if (typeof v.dayOfWeek !== "number") {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`temporal-fmt: isWeekend() needs a value with a dayOfWeek field (PlainDate / PlainDateTime / ZonedDateTime).`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return v.dayOfWeek === 6 || v.dayOfWeek === 7;
|
|
143
|
+
}
|
|
144
|
+
function isWeekday(value) {
|
|
145
|
+
return !isWeekend(value);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
compare,
|
|
150
|
+
isEqual,
|
|
151
|
+
isBefore,
|
|
152
|
+
isAfter,
|
|
153
|
+
min,
|
|
154
|
+
max,
|
|
155
|
+
clamp,
|
|
156
|
+
isBetween,
|
|
157
|
+
isSameDay,
|
|
158
|
+
isToday,
|
|
159
|
+
isTomorrow,
|
|
160
|
+
isYesterday,
|
|
161
|
+
isSameWeek,
|
|
162
|
+
isSameMonth,
|
|
163
|
+
isSameQuarter,
|
|
164
|
+
isSameYear,
|
|
165
|
+
isWeekend,
|
|
166
|
+
isWeekday
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=chunk-UGYSEYUQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/comparison.ts"],"sourcesContent":["/*\n * Copyright 2026 DirazCoder\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Comparison helpers. Pure functions over the field\n// shape, no Temporal namespace needed — same convention as\n// calendarUtils.ts. All comparisons are field-based, not identity-based,\n// so a polyfill PlainDate compares equal to a native PlainDate with the\n// same year/month/day.\n\nimport { asDateFieldView, type DateFieldView } from './calendarUtils.js';\nimport { dayOfWeekFromCivil, daysFromCivil } from './isoWeek.js';\n\ninterface DateTimeFieldView extends DateFieldView {\n hour?: number;\n minute?: number;\n second?: number;\n millisecond?: number;\n}\n\nfunction toComparableMs(view: DateTimeFieldView): number {\n // Exact proleptic-Gregorian day count (Howard Hinnant's days_from_civil,\n // same algorithm arithmetic.ts/interval.ts use) plus the time-of-day —\n // NOT an approximation. The previous implementation multiplied the\n // year offset by an average 365.2425 days/year, on the theory that the\n // error \"is constant for any given year, so it cancels out in a diff\".\n // That's only true when both dates fall in the same year: the year\n // term's error differs by up to ~0.76 days between adjacent years\n // (365.2425 vs 365/366 actual), which corrupts cross-year comparisons\n // near the boundary — e.g. isAfter(2025-01-01T00:00, 2024-12-31T18:12)\n // returned false (truth: ~5.8h after), and isEqual() returned true for\n // instants ~18h apart (2025-01-01T00:00 vs 2024-12-31T05:49:12).\n // Exact arithmetic has no such error term. The day count itself comes\n // from isoWeek.ts's daysFromCivil (Howard Hinnant's days_from_civil:\n // O(1), correct for negative years — the inlined era formula this\n // replaced double-corrected pre-year-0 dates by a day via Math.floor\n // of the -399-offset numerator).\n const days = daysFromCivil(view.year!, view.month!, view.day!);\n\n const MS_PER_HOUR = 3_600_000;\n const MS_PER_MINUTE = 60_000;\n const MS_PER_SECOND = 1_000;\n\n return days * 86_400_000\n + (view.hour ?? 0) * MS_PER_HOUR\n + (view.minute ?? 0) * MS_PER_MINUTE\n + (view.second ?? 0) * MS_PER_SECOND\n + (view.millisecond ?? 0);\n}\n\nfunction asDateTimeFieldView(value: unknown): DateTimeFieldView {\n const v = asDateFieldView(value);\n return v as DateTimeFieldView;\n}\n\n// Returns < 0 if a < b, 0 if a === b, > 0 if a > b. Same convention as\n// Array.prototype.sort and Temporal.PlainDate.compare. Lets callers\n// pass this directly as a comparator.\nexport function compare(a: unknown, b: unknown): number {\n const av = asDateTimeFieldView(a);\n const bv = asDateTimeFieldView(b);\n const am = toComparableMs(av);\n const bm = toComparableMs(bv);\n if (am < bm) return -1;\n if (am > bm) return 1;\n return 0;\n}\n\nexport function isEqual(a: unknown, b: unknown): boolean {\n return compare(a, b) === 0;\n}\n\nexport function isBefore(a: unknown, b: unknown): boolean {\n return compare(a, b) < 0;\n}\n\nexport function isAfter(a: unknown, b: unknown): boolean {\n return compare(a, b) > 0;\n}\n\nexport function min(values: unknown[]): unknown {\n if (!Array.isArray(values) || values.length === 0) {\n throw new Error('temporal-fmt: min() requires a non-empty array of values.');\n }\n let best = values[0];\n for (let i = 1; i < values.length; i++) {\n if (compare(values[i], best) < 0) best = values[i];\n }\n return best;\n}\n\nexport function max(values: unknown[]): unknown {\n if (!Array.isArray(values) || values.length === 0) {\n throw new Error('temporal-fmt: max() requires a non-empty array of values.');\n }\n let best = values[0];\n for (let i = 1; i < values.length; i++) {\n if (compare(values[i], best) > 0) best = values[i];\n }\n return best;\n}\n\nexport function clamp(value: unknown, lo: unknown, hi: unknown): unknown {\n if (compare(value, lo) < 0) return lo;\n if (compare(value, hi) > 0) return hi;\n return value;\n}\n\nexport function isBetween(value: unknown, lo: unknown, hi: unknown): boolean {\n return compare(value, lo) >= 0 && compare(value, hi) <= 0;\n}\n\n// Semantic helpers — same-day/week/month/quarter/year tests. Useful for\n// UI (\"is this event today?\") and for grouping/aggregation. All take a\n// reference value to compare against; the \"isToday\" / \"isTomorrow\" /\n// \"isYesterday\" variants compute the reference from the current system\n// date themselves so callers don't have to.\nfunction readYearMonthDay(value: unknown): { year: number; month: number; day: number } {\n const v = asDateFieldView(value);\n return { year: v.year!, month: v.month!, day: v.day! };\n}\n\nfunction todayYearMonthDay(): { year: number; month: number; day: number } {\n const now = new Date();\n return { year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate() };\n}\n\nfunction dateEqualYearMonthDay(a: { year: number; month: number; day: number }, b: { year: number; month: number; day: number }): boolean {\n return a.year === b.year && a.month === b.month && a.day === b.day;\n}\n\nexport function isSameDay(value: unknown, reference: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), readYearMonthDay(reference));\n}\n\nexport function isToday(value: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), todayYearMonthDay());\n}\n\nfunction tomorrowYearMonthDay(): { year: number; month: number; day: number } {\n const d = new Date();\n d.setDate(d.getDate() + 1);\n return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };\n}\n\nfunction yesterdayYearMonthDay(): { year: number; month: number; day: number } {\n const d = new Date();\n d.setDate(d.getDate() - 1);\n return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };\n}\n\nexport function isTomorrow(value: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), tomorrowYearMonthDay());\n}\n\nexport function isYesterday(value: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), yesterdayYearMonthDay());\n}\n\nfunction sameWeek(yearA: number, monthA: number, dayA: number, yearB: number, monthB: number, dayB: number): boolean {\n // Same week iff the dates are within 7 days of each other AND the earlier\n // one's weekday is ≤ the later one's weekday (so we don't say \"Sun and\n // the following Mon are in the same week\" — ISO weeks run Mon-Sun).\n // Easier: compute ISO week numbers via isoWeekYearAndWeek, compare both\n // year and week. That handles the year-boundary case (Dec 31 vs Jan 1 of\n // the next year, which can be in the same ISO week).\n // Local import to avoid module-cycle: isoWeek.ts doesn't import from here.\n // Lazy require-style dynamic via inline static import at top would be\n // cleaner; this inline computation is fine for a pure helper.\n // ...actually let's just compute weekday offsets directly. Same-ISO-week\n // iff |d1 - d2| < 7 days AND the earlier date's ISO weekday ≤ the later\n // date's ISO weekday so they fall in the same Mon-Sun span.\n const daysSince = (y: number, m: number, d: number): number => {\n // daysFromCivil: O(1), correct for negative years. (The inlined\n // formula this replaced was the one remaining copy of the\n // Math.floor-of-offset era bug — see daysFromCivil's comment.)\n return daysFromCivil(y, m, d);\n };\n const a = daysSince(yearA, monthA, dayA);\n const b = daysSince(yearB, monthB, dayB);\n if (Math.abs(a - b) >= 7) return false;\n // Same week iff both dates round to the same Monday. Compute the\n // Monday-of-week for each: subtract (weekday - 1) days, where weekday\n // is 1=Mon..7=Sun. Use the standard Zeller formula for weekday.\n const weekdayOf = (y: number, m: number, d: number): number => {\n // O(1) proleptic-Gregorian weekday from isoWeek.ts's dayOfWeekFromCivil.\n // The old Date.UTC(y, m-1, d) form remapped years 0-99 to 1900-1999\n // (ECMAScript spec), computing the weekday of the wrong century for\n // first-century dates.\n return dayOfWeekFromCivil(y, m, d);\n };\n const wa = a - (weekdayOf(yearA, monthA, dayA) - 1);\n const wb = b - (weekdayOf(yearB, monthB, dayB) - 1);\n return wa === wb;\n}\n\nexport function isSameWeek(value: unknown, reference: unknown): boolean {\n const a = readYearMonthDay(value);\n const b = readYearMonthDay(reference);\n return sameWeek(a.year, a.month, a.day, b.year, b.month, b.day);\n}\n\nexport function isSameMonth(value: unknown, reference: unknown): boolean {\n const a = readYearMonthDay(value);\n const b = readYearMonthDay(reference);\n return a.year === b.year && a.month === b.month;\n}\n\nexport function isSameQuarter(value: unknown, reference: unknown): boolean {\n const a = readYearMonthDay(value);\n const b = readYearMonthDay(reference);\n return a.year === b.year && Math.ceil(a.month / 3) === Math.ceil(b.month / 3);\n}\n\nexport function isSameYear(value: unknown, reference: unknown): boolean {\n return readYearMonthDay(value).year === readYearMonthDay(reference).year;\n}\n\n// isWeekend / isWeekday depend on dayOfWeek — present on PlainDate,\n// PlainDateTime, ZonedDateTime, but NOT on PlainTime. Callers passing\n// PlainTime get a descriptive throw. Doesn't call asDateFieldView\n// because that would reject PlainTime (no year/month/day) before\n// reaching the dayOfWeek check — and the error we want here is the\n// \"no dayOfWeek field\" one, not the \"no date fields\" one.\nexport function isWeekend(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) {\n throw new Error(`temporal-fmt: isWeekend() expected a Temporal value, got ${String(value)}.`);\n }\n const v = value as { dayOfWeek?: unknown };\n if (typeof v.dayOfWeek !== 'number') {\n throw new Error(\n `temporal-fmt: isWeekend() needs a value with a dayOfWeek field (PlainDate / PlainDateTime / ZonedDateTime).`\n );\n }\n // 6=Sat, 7=Sun in Temporal's Mon=1..Sun=7 numbering.\n return v.dayOfWeek === 6 || v.dayOfWeek === 7;\n}\n\nexport function isWeekday(value: unknown): boolean {\n return !isWeekend(value);\n}\n"],"mappings":";;;;;;;;;AAgCA,SAAS,eAAe,MAAiC;AAiBvD,QAAM,OAAO,cAAc,KAAK,MA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EAAE;AAC5C;AAEO,SAAS,cAAc,OAAgB,WAA6B;AACzE,QAAM,IAAI,iBAAiB,KAAK;AAChC,QAAM,IAAI,iBAAiB,SAAS;AACpC,SAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,KAAK,EAAE,QAAQ,CAAC,MAAM,KAAK,KAAK,EAAE,QAAQ,CAAC;AAC9E;AAEO,SAAS,WAAW,OAAgB,WAA6B;AACtE,SAAO,iBAAiB,KAAK,EAAE,SAAS,iBAAiB,SAAS,EAAE;AACtE;AAQO,SAAS,UAAU,OAAyB;AACjD,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,UAAM,IAAI,MAAM,4DAA4D,OAAO,KAAK,CAAC,GAAG;AAAA,EAC9F;AACA,QAAM,IAAI;AACV,MAAI,OAAO,EAAE,cAAc,UAAU;AACnC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,cAAc,KAAK,EAAE,cAAc;AAC9C;AAEO,SAAS,UAAU,OAAyB;AACjD,SAAO,CAAC,UAAU,KAAK;AACzB;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCALE
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Z245NHDT.js";
|
|
4
4
|
import {
|
|
5
5
|
InvalidLocaleError,
|
|
6
6
|
normalizeLocaleTag
|
|
@@ -62,4 +62,4 @@ export {
|
|
|
62
62
|
formatRelative,
|
|
63
63
|
formatRelativeToNow
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-WEVNKOQA.js.map
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {
|
|
2
|
+
format,
|
|
3
|
+
formatToParts
|
|
4
|
+
} from "./chunk-HGRT37LT.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeLocaleTag
|
|
7
|
+
} from "./chunk-QRLQ7RR7.js";
|
|
8
|
+
import {
|
|
9
|
+
compare
|
|
10
|
+
} from "./chunk-UGYSEYUQ.js";
|
|
11
|
+
import {
|
|
12
|
+
asDateFieldView
|
|
13
|
+
} from "./chunk-KEPIXQK7.js";
|
|
14
|
+
import {
|
|
15
|
+
daysFromCivil
|
|
16
|
+
} from "./chunk-BLZDBPSV.js";
|
|
17
|
+
|
|
18
|
+
// src/interval.ts
|
|
19
|
+
function interval(start, end, bounds = "closed") {
|
|
20
|
+
const cmp = compare(start, end);
|
|
21
|
+
if (cmp > 0) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`temporal-fmt: interval start must be \u2264 end (got start > end). Pass them in chronological order.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return { start, end, bounds };
|
|
27
|
+
}
|
|
28
|
+
function startIncluded(bounds) {
|
|
29
|
+
return bounds === "closed" || bounds === "half-open-end";
|
|
30
|
+
}
|
|
31
|
+
function endIncluded(bounds) {
|
|
32
|
+
return bounds === "closed" || bounds === "half-open-start";
|
|
33
|
+
}
|
|
34
|
+
function contains(iv, value) {
|
|
35
|
+
const startCmp = compare(value, iv.start);
|
|
36
|
+
const endCmp = compare(value, iv.end);
|
|
37
|
+
const afterStart = startIncluded(iv.bounds) ? startCmp >= 0 : startCmp > 0;
|
|
38
|
+
const beforeEnd = endIncluded(iv.bounds) ? endCmp <= 0 : endCmp < 0;
|
|
39
|
+
return afterStart && beforeEnd;
|
|
40
|
+
}
|
|
41
|
+
function overlaps(a, b) {
|
|
42
|
+
return intersects(a, b);
|
|
43
|
+
}
|
|
44
|
+
function intersects(a, b) {
|
|
45
|
+
const loCmp = compare(a.start, b.start);
|
|
46
|
+
const lo = loCmp >= 0 ? a.start : b.start;
|
|
47
|
+
const hiCmp = compare(a.end, b.end);
|
|
48
|
+
const hi = hiCmp <= 0 ? a.end : b.end;
|
|
49
|
+
const inner = compare(lo, hi);
|
|
50
|
+
if (inner < 0) return true;
|
|
51
|
+
if (inner > 0) return false;
|
|
52
|
+
return contains(a, lo) && contains(b, lo);
|
|
53
|
+
}
|
|
54
|
+
function isBefore(a, b) {
|
|
55
|
+
return compare(a.end, b.start) < 0;
|
|
56
|
+
}
|
|
57
|
+
function isAfter(a, b) {
|
|
58
|
+
return compare(a.start, b.end) > 0;
|
|
59
|
+
}
|
|
60
|
+
function intersection(a, b) {
|
|
61
|
+
if (!intersects(a, b)) return null;
|
|
62
|
+
const aStartLater = compare(a.start, b.start) > 0;
|
|
63
|
+
const start = aStartLater ? a.start : b.start;
|
|
64
|
+
const aEndEarlier = compare(a.end, b.end) < 0;
|
|
65
|
+
const end = aEndEarlier ? a.end : b.end;
|
|
66
|
+
const startInc = aStartLater ? startIncluded(a.bounds) : compare(b.start, a.start) > 0 ? startIncluded(b.bounds) : startIncluded(a.bounds) && startIncluded(b.bounds);
|
|
67
|
+
const endInc = aEndEarlier ? endIncluded(a.bounds) : compare(a.end, b.end) > 0 ? endIncluded(b.bounds) : endIncluded(a.bounds) && endIncluded(b.bounds);
|
|
68
|
+
const bounds = startInc ? endInc ? "closed" : "half-open-end" : endInc ? "half-open-start" : "open";
|
|
69
|
+
return { start, end, bounds };
|
|
70
|
+
}
|
|
71
|
+
function union(a, b) {
|
|
72
|
+
if (!intersects(a, b)) return null;
|
|
73
|
+
const aStartEarlier = compare(a.start, b.start) < 0;
|
|
74
|
+
const start = aStartEarlier ? a.start : b.start;
|
|
75
|
+
const aEndLater = compare(a.end, b.end) > 0;
|
|
76
|
+
const end = aEndLater ? a.end : b.end;
|
|
77
|
+
const startInc = aStartEarlier ? startIncluded(a.bounds) : compare(b.start, a.start) < 0 ? startIncluded(b.bounds) : startIncluded(a.bounds) || startIncluded(b.bounds);
|
|
78
|
+
const endInc = aEndLater ? endIncluded(a.bounds) : compare(a.end, b.end) < 0 ? endIncluded(b.bounds) : endIncluded(a.bounds) || endIncluded(b.bounds);
|
|
79
|
+
const bounds = startInc ? endInc ? "closed" : "half-open-end" : endInc ? "half-open-start" : "open";
|
|
80
|
+
return { start, end, bounds };
|
|
81
|
+
}
|
|
82
|
+
function difference(a, b) {
|
|
83
|
+
if (!intersects(a, b)) return [a];
|
|
84
|
+
const result = [];
|
|
85
|
+
if (compare(a.start, b.start) < 0) {
|
|
86
|
+
const endInc = contains(a, b.start) && !contains(b, b.start);
|
|
87
|
+
result.push({
|
|
88
|
+
start: a.start,
|
|
89
|
+
end: b.start,
|
|
90
|
+
bounds: startIncluded(a.bounds) ? endInc ? "closed" : "half-open-end" : endInc ? "half-open-start" : "open"
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (compare(a.end, b.end) > 0) {
|
|
94
|
+
const startInc = contains(a, b.end) && !contains(b, b.end);
|
|
95
|
+
result.push({
|
|
96
|
+
start: b.end,
|
|
97
|
+
end: a.end,
|
|
98
|
+
bounds: startInc ? endIncluded(a.bounds) ? "closed" : "half-open-end" : endIncluded(a.bounds) ? "half-open-start" : "open"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
var subtract = difference;
|
|
104
|
+
function mergeIntervals(intervals) {
|
|
105
|
+
if (intervals.length === 0) return [];
|
|
106
|
+
const sorted = [...intervals].sort((a, b) => compare(a.start, b.start));
|
|
107
|
+
const result = [{ ...sorted[0] }];
|
|
108
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
109
|
+
const current = sorted[i];
|
|
110
|
+
const last = result[result.length - 1];
|
|
111
|
+
const touching = compare(last.end, current.start) === 0;
|
|
112
|
+
const touchMerges = touching && (endIncluded(last.bounds) || startIncluded(current.bounds));
|
|
113
|
+
if (intersects(last, current) || touchMerges) {
|
|
114
|
+
const endCmp = compare(current.end, last.end);
|
|
115
|
+
if (endCmp > 0) {
|
|
116
|
+
last.end = current.end;
|
|
117
|
+
last.bounds = startIncluded(last.bounds) ? endIncluded(current.bounds) ? "closed" : "half-open-end" : endIncluded(current.bounds) ? "half-open-start" : "open";
|
|
118
|
+
} else if (endCmp === 0) {
|
|
119
|
+
last.bounds = startIncluded(last.bounds) ? endIncluded(last.bounds) || endIncluded(current.bounds) ? "closed" : "half-open-end" : endIncluded(last.bounds) || endIncluded(current.bounds) ? "half-open-start" : "open";
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
result.push({ ...current });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
var MAX_DATE_MS = 864e13;
|
|
128
|
+
function splitInterval(iv, n) {
|
|
129
|
+
if (n <= 0) throw new Error(`temporal-fmt: splitInterval requires n > 0 (got ${n}).`);
|
|
130
|
+
if (n === 1) return [iv];
|
|
131
|
+
const startFields = asDateFieldView(iv.start);
|
|
132
|
+
const endFields = asDateFieldView(iv.end);
|
|
133
|
+
const startMs = toMs(startFields);
|
|
134
|
+
const endMs = toMs(endFields);
|
|
135
|
+
if (Math.abs(startMs) > MAX_DATE_MS || Math.abs(endMs) > MAX_DATE_MS) {
|
|
136
|
+
throw new RangeError(
|
|
137
|
+
`temporal-fmt: splitInterval() endpoints are outside the representable Date range (approximately \xB1275,760 years). Split the interval into smaller ranges first.`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const step = (endMs - startMs) / n;
|
|
141
|
+
const result = [];
|
|
142
|
+
const ivStartInc = startIncluded(iv.bounds);
|
|
143
|
+
const ivEndInc = endIncluded(iv.bounds);
|
|
144
|
+
for (let i = 0; i < n; i++) {
|
|
145
|
+
const sliceStart = startMs + i * step;
|
|
146
|
+
const sliceEnd = i === n - 1 ? endMs : sliceStart + step;
|
|
147
|
+
const startInc = i === 0 ? ivStartInc : true;
|
|
148
|
+
const endInc = i === n - 1 ? ivEndInc : false;
|
|
149
|
+
result.push({
|
|
150
|
+
start: fromMs(sliceStart, startFields),
|
|
151
|
+
end: fromMs(sliceEnd, endFields),
|
|
152
|
+
// The 'half-open-start' arm on the last line below is structurally
|
|
153
|
+
// unreachable: startInc is false only for slice 0 (later slices
|
|
154
|
+
// start included), and slice 0's endInc is always false (only the
|
|
155
|
+
// last slice carries the input's end inclusivity) — a slice with an
|
|
156
|
+
// exclusive start AND inclusive end would require n === 1, which
|
|
157
|
+
// returns [iv] unchanged above. The other arms are live and covered.
|
|
158
|
+
/* c8 ignore next 3 @preserve */
|
|
159
|
+
bounds: startInc ? endInc ? "closed" : "half-open-end" : endInc ? "half-open-start" : "open"
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
function toMs(v) {
|
|
165
|
+
const days = daysFromCivil(v.year, v.month, v.day);
|
|
166
|
+
return days * 864e5 + (v.hour ?? 0) * 36e5 + (v.minute ?? 0) * 6e4 + (v.second ?? 0) * 1e3 + (v.millisecond ?? 0);
|
|
167
|
+
}
|
|
168
|
+
function fromMs(ms, base) {
|
|
169
|
+
const MS_PER_DAY = 864e5;
|
|
170
|
+
const dayOverflow = Math.floor(ms / MS_PER_DAY);
|
|
171
|
+
let withinDay = ms % MS_PER_DAY;
|
|
172
|
+
if (withinDay < 0) withinDay += MS_PER_DAY;
|
|
173
|
+
const hour = Math.floor(withinDay / 36e5);
|
|
174
|
+
const minute = Math.floor(withinDay % 36e5 / 6e4);
|
|
175
|
+
const second = Math.floor(withinDay % 6e4 / 1e3);
|
|
176
|
+
const millisecond = withinDay % 1e3;
|
|
177
|
+
const newMs = dayOverflow * MS_PER_DAY;
|
|
178
|
+
const d = new Date(newMs);
|
|
179
|
+
return {
|
|
180
|
+
...base,
|
|
181
|
+
year: d.getUTCFullYear(),
|
|
182
|
+
month: d.getUTCMonth() + 1,
|
|
183
|
+
day: d.getUTCDate(),
|
|
184
|
+
hour,
|
|
185
|
+
minute,
|
|
186
|
+
second,
|
|
187
|
+
millisecond
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function formatRange(iv, formatStr, options = {}) {
|
|
191
|
+
try {
|
|
192
|
+
const startStr = format(iv.start, formatStr, options);
|
|
193
|
+
const endStr = format(iv.end, formatStr, options);
|
|
194
|
+
return `${startStr} \u2013 ${endStr}`;
|
|
195
|
+
} catch (err) {
|
|
196
|
+
try {
|
|
197
|
+
const fmt = new Intl.DateTimeFormat(normalizeLocaleTag(options.locale ?? "en-US"), {});
|
|
198
|
+
const startDate = toJSDate(iv.start);
|
|
199
|
+
const endDate = toJSDate(iv.end);
|
|
200
|
+
return fmt.formatRange(startDate, endDate);
|
|
201
|
+
} catch {
|
|
202
|
+
throw err;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function formatRangeToParts(iv, formatStr, options = {}) {
|
|
207
|
+
const startParts = formatToParts(iv.start, formatStr, options);
|
|
208
|
+
const endParts = formatToParts(iv.end, formatStr, options);
|
|
209
|
+
const result = [...startParts];
|
|
210
|
+
result.push({ type: "literal", value: " \u2013 " });
|
|
211
|
+
result.push(...endParts);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
function toJSDate(value) {
|
|
215
|
+
const v = value;
|
|
216
|
+
if (typeof v?.toInstant === "function") {
|
|
217
|
+
return new Date(v.toInstant().epochMilliseconds);
|
|
218
|
+
}
|
|
219
|
+
if (typeof v?.year === "number" && typeof v?.month === "number" && typeof v?.day === "number") {
|
|
220
|
+
return new Date(Date.UTC(v.year, v.month - 1, v.day, v.hour ?? 0, v.minute ?? 0, v.second ?? 0, v.millisecond ?? 0));
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`temporal-fmt: formatRange() expected Temporal values with year/month/day, got ${typeof value}.`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export {
|
|
226
|
+
interval,
|
|
227
|
+
contains,
|
|
228
|
+
overlaps,
|
|
229
|
+
intersects,
|
|
230
|
+
isBefore,
|
|
231
|
+
isAfter,
|
|
232
|
+
intersection,
|
|
233
|
+
union,
|
|
234
|
+
difference,
|
|
235
|
+
subtract,
|
|
236
|
+
mergeIntervals,
|
|
237
|
+
splitInterval,
|
|
238
|
+
formatRange,
|
|
239
|
+
formatRangeToParts
|
|
240
|
+
};
|
|
241
|
+
//# sourceMappingURL=chunk-WP7TBCTT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interval.ts"],"sourcesContent":["/*\n * Copyright 2026 DirazCoder\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Intervals / ranges. An interval is a pair of\n// (start, end) Temporal values with bounds semantics: open, closed,\n// or half-open. Operations: contains, overlaps, intersects, isBefore,\n// isAfter, intersection, union, difference, subtract, mergeIntervals,\n// splitInterval. Plus formatRange / formatRangeToParts with intelligent\n// collapsing.\n//\n// All operations are field-based (no instanceof), matching the rest of\n// the library. Internally uses the comparison helpers from comparison.ts\n// to order endpoints.\n\nimport { compare } from './comparison.js';\nimport { formatToParts, format as baseFormat, type FormattedPart } from './format.js';\nimport { asDateFieldView, type DateFieldView } from './calendarUtils.js';\nimport { normalizeLocaleTag } from './localeVocab.js';\nimport { daysFromCivil } from './isoWeek.js';\nimport type { FormatOptions } from './tokens.js';\n\nexport type IntervalBounds = 'open' | 'closed' | 'half-open-start' | 'half-open-end';\n\nexport interface Interval {\n start: unknown;\n end: unknown;\n bounds: IntervalBounds;\n}\n\nexport function interval(start: unknown, end: unknown, bounds: IntervalBounds = 'closed'): Interval {\n // Validate that start ≤ end, otherwise the interval is malformed.\n const cmp = compare(start, end);\n if (cmp > 0) {\n throw new Error(\n `temporal-fmt: interval start must be ≤ end (got start > end). Pass them in chronological order.`\n );\n }\n return { start, end, bounds };\n}\n\n// Inclusive containment check accounting for bounds semantics.\n// - 'closed': [start, end] — both endpoints included\n// - 'open': (start, end) — neither endpoint included\n// - 'half-open-start': (start, end] — start excluded, end included\n// - 'half-open-end': [start, end) — start included, end excluded\n//\n// The two half-open conditions below used to have their labels swapped —\n// 'half-open-end' excluded the start and included the end (the exact\n// behavior 'half-open-start' documents, and vice versa) — which made\n// contains() disagree with difference() (whose labels were correct all\n// along) and silently broke splitInterval's partition (see below).\n// startOpen/beginOpen naming below says which *endpoint* is excluded, so\n// the mapping to the label can't drift again.\nfunction startIncluded(bounds: IntervalBounds): boolean {\n return bounds === 'closed' || bounds === 'half-open-end';\n}\nfunction endIncluded(bounds: IntervalBounds): boolean {\n return bounds === 'closed' || bounds === 'half-open-start';\n}\n\nexport function contains(iv: Interval, value: unknown): boolean {\n const startCmp = compare(value, iv.start);\n const endCmp = compare(value, iv.end);\n const afterStart = startIncluded(iv.bounds) ? startCmp >= 0 : startCmp > 0;\n const beforeEnd = endIncluded(iv.bounds) ? endCmp <= 0 : endCmp < 0;\n return afterStart && beforeEnd;\n}\n\n// Two intervals overlap iff their ranges intersect, regardless of bounds.\n// intersects() is the boolean form; intersection() returns the actual\n// overlap interval.\nexport function overlaps(a: Interval, b: Interval): boolean {\n return intersects(a, b);\n}\n\nexport function intersects(a: Interval, b: Interval): boolean {\n // Two intervals intersect iff they share at least one point. The old\n // version returned true whenever the spans touched, regardless of\n // bounds — so (Jan 1, Jan 5) and (Jan 5, Jan 10), which share no point\n // (Jan 5 belongs to neither), reported as overlapping, and\n // intersection() returned a degenerate non-empty-looking result for\n // the empty intersection. Computing the candidate shared span and\n // consulting contains() at the single shared point handles every\n // bounds combination uniformly.\n const loCmp = compare(a.start, b.start);\n const lo = loCmp >= 0 ? a.start : b.start; // later start\n const hiCmp = compare(a.end, b.end);\n const hi = hiCmp <= 0 ? a.end : b.end; // earlier end\n const inner = compare(lo, hi);\n if (inner < 0) return true; // strictly inside — a real span is shared\n if (inner > 0) return false; // spans don't reach each other\n // lo === hi: the only possible shared point is that single value —\n // it has to be contained in BOTH intervals.\n return contains(a, lo) && contains(b, lo);\n}\n\nexport function isBefore(a: Interval, b: Interval): boolean {\n return compare(a.end, b.start) < 0;\n}\n\nexport function isAfter(a: Interval, b: Interval): boolean {\n return compare(a.start, b.end) > 0;\n}\n\n// Returns the intersection of two intervals, or null if they don't\n// overlap. The result's bounds at each endpoint come from whichever\n// interval OWNS that endpoint (the later start, the earlier end) — when\n// both intervals supply the same endpoint, intersection inclusivity is\n// the AND of the two (a point is in a∩b only if it's in both).\nexport function intersection(a: Interval, b: Interval): Interval | null {\n if (!intersects(a, b)) return null;\n const aStartLater = compare(a.start, b.start) > 0;\n const start = aStartLater ? a.start : b.start;\n const aEndEarlier = compare(a.end, b.end) < 0;\n const end = aEndEarlier ? a.end : b.end;\n // Start-side inclusivity: owned by the later-start interval, or the\n // conjunction when the starts are equal.\n const startInc = aStartLater\n ? startIncluded(a.bounds)\n : compare(b.start, a.start) > 0\n ? startIncluded(b.bounds)\n : startIncluded(a.bounds) && startIncluded(b.bounds);\n // End-side inclusivity: owned by the earlier-end interval, or the\n // conjunction when the ends are equal.\n const endInc = aEndEarlier\n ? endIncluded(a.bounds)\n : compare(a.end, b.end) > 0\n ? endIncluded(b.bounds)\n : endIncluded(a.bounds) && endIncluded(b.bounds);\n const bounds: IntervalBounds = startInc\n ? (endInc ? 'closed' : 'half-open-end')\n : (endInc ? 'half-open-start' : 'open');\n return { start, end, bounds };\n}\n\n// Returns the union of two intervals (the smallest interval containing\n// both), or null if they don't overlap (caller should use mergeIntervals\n// for that case). Union inclusivity at each endpoint comes from the\n// interval that extends further, or the disjunction when both reach the\n// same endpoint.\nexport function union(a: Interval, b: Interval): Interval | null {\n if (!intersects(a, b)) return null;\n const aStartEarlier = compare(a.start, b.start) < 0;\n const start = aStartEarlier ? a.start : b.start;\n const aEndLater = compare(a.end, b.end) > 0;\n const end = aEndLater ? a.end : b.end;\n const startInc = aStartEarlier\n ? startIncluded(a.bounds)\n : compare(b.start, a.start) < 0\n ? startIncluded(b.bounds)\n : startIncluded(a.bounds) || startIncluded(b.bounds);\n const endInc = aEndLater\n ? endIncluded(a.bounds)\n : compare(a.end, b.end) < 0\n ? endIncluded(b.bounds)\n : endIncluded(a.bounds) || endIncluded(b.bounds);\n const bounds: IntervalBounds = startInc\n ? (endInc ? 'closed' : 'half-open-end')\n : (endInc ? 'half-open-start' : 'open');\n return { start, end, bounds };\n}\n\n// Returns the part of `a` that is not in `b`. May produce 0, 1, or 2\n// intervals depending on the overlap shape.\n//\n// Bounds semantics: each surviving piece keeps the inclusivity of the\n// original endpoint it inherits from `a`, and the endpoint created by the\n// cut is always exclusive (it is `b`'s edge, which belongs to the removed\n// overlap). The old implementation derived both bounds from a lossy\n// helper that collapsed several of these combinations — the pieces'\n// endpoints were right, but the bounds metadata was stricter than the\n// actual remainder for open/half-open inputs.\nexport function difference(a: Interval, b: Interval): Interval[] {\n if (!intersects(a, b)) return [a];\n const result: Interval[] = [];\n // Part of `a` before `b` starts. Its end is b.start; that point stays\n // in the remainder iff a still contains it AND b doesn't — a cut edge\n // is only removed when the removed interval actually includes it (a\n // cut against an open-bounded b used to drop the edge point even\n // though b never owned it).\n if (compare(a.start, b.start) < 0) {\n const endInc = contains(a, b.start) && !contains(b, b.start);\n result.push({\n start: a.start,\n end: b.start,\n bounds: startIncluded(a.bounds)\n ? (endInc ? 'closed' : 'half-open-end')\n : (endInc ? 'half-open-start' : 'open'),\n });\n }\n // Part of `a` after `b` ends — mirror image of the above.\n if (compare(a.end, b.end) > 0) {\n const startInc = contains(a, b.end) && !contains(b, b.end);\n result.push({\n start: b.end,\n end: a.end,\n bounds: startInc\n ? (endIncluded(a.bounds) ? 'closed' : 'half-open-end')\n : (endIncluded(a.bounds) ? 'half-open-start' : 'open'),\n });\n }\n return result;\n}\n\n// Alias for difference() — \"subtract\" reads more naturally at some\n// call sites than \"difference\" does.\nexport const subtract = difference;\n\n// Merges a list of intervals, combining overlapping ones. Returns a\n// sorted list of disjoint intervals. The inputs are treated as\n// immutable — the merged result carries shallow copies of any interval\n// object it extends, so a caller's own `end` reference is never\n// reassigned under them (mergeIntervals used to write `last.end =\n// current.end` straight into the caller's object).\nexport function mergeIntervals(intervals: Interval[]): Interval[] {\n if (intervals.length === 0) return [];\n const sorted = [...intervals].sort((a, b) => compare(a.start, b.start));\n // Shallow-copy EVERY interval placed into the result, not just the\n // first — the inputs are documented as immutable and the merged\n // object is mutated below (last.end is reassigned), so aliasing any\n // input would write through to the caller's objects. Non-merged\n // intervals used to be pushed by reference.\n const result: Interval[] = [{ ...sorted[0]! }];\n for (let i = 1; i < sorted.length; i++) {\n const current = sorted[i]!;\n const last = result[result.length - 1]!;\n // Touching endpoints merge only when at least one interval actually\n // contains the shared point — [1,5) + [5,10] union to [1,10], but\n // (1,5) + (5,10) leave a hole at exactly 5 and must stay separate.\n // (Plain overlaps always merge, per intersects().)\n const touching = compare(last.end, current.start) === 0;\n const touchMerges = touching && (endIncluded(last.bounds) || startIncluded(current.bounds));\n if (intersects(last, current) || touchMerges) {\n // Extend to the farther end, carrying that interval's end\n // inclusivity over (and when the ends are equal, the union of the\n // two end inclusivities).\n const endCmp = compare(current.end, last.end);\n if (endCmp > 0) {\n last.end = current.end;\n last.bounds = startIncluded(last.bounds)\n ? (endIncluded(current.bounds) ? 'closed' : 'half-open-end')\n : (endIncluded(current.bounds) ? 'half-open-start' : 'open');\n } else if (endCmp === 0) {\n last.bounds = startIncluded(last.bounds)\n ? (endIncluded(last.bounds) || endIncluded(current.bounds) ? 'closed' : 'half-open-end')\n : (endIncluded(last.bounds) || endIncluded(current.bounds) ? 'half-open-start' : 'open');\n }\n } else {\n result.push({ ...current });\n }\n }\n return result;\n}\n\n// Widest instant JS Date can represent (±8.64e15 ms, i.e. ±100,000,000\n// days from the Unix epoch). splitInterval rebuilds endpoints via Date,\n// so anything outside this window would silently produce Invalid Date\n// objects with NaN year/month/day fields — reject it descriptively\n// instead.\nconst MAX_DATE_MS = 8.64e15;\n\n// Splits an interval into N equal sub-intervals. Throws if N ≤ 0.\n// Equality is by ms-distance between start and end — for date ranges\n// this approximates \"equal time slices\", which is the most useful\n// interpretation. For calendar-bound splits (e.g. \"split this month\n// into weeks\"), callers should use recurrence() instead.\nexport function splitInterval(iv: Interval, n: number): Interval[] {\n if (n <= 0) throw new Error(`temporal-fmt: splitInterval requires n > 0 (got ${n}).`);\n if (n === 1) return [iv];\n const startFields = asDateFieldView(iv.start) as DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number };\n const endFields = asDateFieldView(iv.end) as DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number };\n const startMs = toMs(startFields);\n const endMs = toMs(endFields);\n if (Math.abs(startMs) > MAX_DATE_MS || Math.abs(endMs) > MAX_DATE_MS) {\n throw new RangeError(\n `temporal-fmt: splitInterval() endpoints are outside the representable Date range ` +\n `(approximately ±275,760 years). Split the interval into smaller ranges first.`\n );\n }\n const step = (endMs - startMs) / n;\n const result: Interval[] = [];\n // A partition: slice 0 keeps the caller's start inclusivity, slices\n // 1..n-1 start exactly where the previous slice ended (exclusively),\n // so their starts are INCLUDED, and every slice except the last\n // excludes its end; the last slice keeps the caller's end inclusivity.\n // Together: [s0, s1) [s1, s2) ... [s_{n-1}, s_n] for a closed input —\n // every point in exactly one slice. (The old version labeled the\n // middle slices 'half-open-start' — which under the pre-fix, swapped\n // contains() semantics accidentally behaved like [s, e) — and left\n // the ORIGINAL end point out of the last slice entirely.)\n const ivStartInc = startIncluded(iv.bounds);\n const ivEndInc = endIncluded(iv.bounds);\n for (let i = 0; i < n; i++) {\n const sliceStart = startMs + i * step;\n const sliceEnd = i === n - 1 ? endMs : sliceStart + step;\n const startInc = i === 0 ? ivStartInc : true;\n const endInc = i === n - 1 ? ivEndInc : false;\n result.push({\n start: fromMs(sliceStart, startFields),\n end: fromMs(sliceEnd, endFields),\n // The 'half-open-start' arm on the last line below is structurally\n // unreachable: startInc is false only for slice 0 (later slices\n // start included), and slice 0's endInc is always false (only the\n // last slice carries the input's end inclusivity) — a slice with an\n // exclusive start AND inclusive end would require n === 1, which\n // returns [iv] unchanged above. The other arms are live and covered.\n /* c8 ignore next 3 @preserve */\n bounds: startInc\n ? (endInc ? 'closed' : 'half-open-end')\n : (endInc ? 'half-open-start' : 'open'),\n });\n }\n return result;\n}\n\nfunction toMs(v: DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number }): number {\n // daysFromCivil (isoWeek.ts) is the O(1) Hinnant day count, correct\n // for negative years. The formula previously inlined here carried a\n // Math.floor applied to Hinnant's -399-offset numerator — a double\n // correction that shifted every pre-year-0 date by one day (the\n // offset form is only equivalent under truncating division, which JS\n // doesn't have).\n const days = daysFromCivil(v.year!, v.month!, v.day!);\n return days * 86_400_000\n + (v.hour ?? 0) * 3_600_000\n + (v.minute ?? 0) * 60_000\n + (v.second ?? 0) * 1_000\n + (v.millisecond ?? 0);\n}\n\nfunction fromMs(ms: number, base: DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number }): DateFieldView {\n const MS_PER_DAY = 86_400_000;\n const dayOverflow = Math.floor(ms / MS_PER_DAY);\n let withinDay = ms % MS_PER_DAY;\n if (withinDay < 0) withinDay += MS_PER_DAY;\n const hour = Math.floor(withinDay / 3_600_000);\n const minute = Math.floor((withinDay % 3_600_000) / 60_000);\n const second = Math.floor((withinDay % 60_000) / 1_000);\n const millisecond = withinDay % 1_000;\n // `ms` (and therefore `dayOverflow`) is already an absolute epoch-ms /\n // epoch-day value — toMs() computed it via Howard Hinnant's algorithm\n // from scratch, not as an offset from `base`. So the date only needs\n // reconstructing from the Unix epoch itself; `base` is just a template\n // for whatever extra (non-date) fields get spread into the result.\n // (Previously this added dayOverflow on top of base's own epoch-ms,\n // double-counting base's offset and landing tens of thousands of days\n // away from the intended date for any non-epoch base.)\n const newMs = dayOverflow * MS_PER_DAY;\n const d = new Date(newMs);\n return {\n ...base,\n year: d.getUTCFullYear(),\n month: d.getUTCMonth() + 1,\n day: d.getUTCDate(),\n hour,\n minute,\n second,\n millisecond,\n };\n}\n\n// Formats an interval as a single string, collapsing shared fields.\n// E.g. \"August 4 – August 6, 2026\" rather than \"August 4, 2026 – August 6, 2026\".\n// Uses Intl.DateTimeFormat's formatRange when available (most engines),\n// falling back to format(start, fmt) + '–' + format(end, fmt) when not.\n\nexport function formatRange(\n iv: Interval,\n formatStr: string,\n options: FormatOptions = {},\n): string {\n // The formatStr parameter is this function's contract — the caller\n // asked for their token format on both endpoints. Honor it first:\n // format each side with the caller's format string and join with an\n // en dash. (This used to try Intl.DateTimeFormat.formatRange() first,\n // which ignores formatStr entirely — formatRange(iv, 'yyyy-MM-dd')\n // silently returned locale-default output like \"8/4/2026 – 8/6/2026\"\n // instead of \"2026-08-04 – 2026-08-06\".) Intl's range collapsing is\n // kept as a fallback for inputs the token path can't render.\n try {\n const startStr = baseFormat(iv.start as Parameters<typeof baseFormat>[0], formatStr, options);\n const endStr = baseFormat(iv.end as Parameters<typeof baseFormat>[0], formatStr, options);\n return `${startStr} – ${endStr}`;\n } catch (err) {\n // Fallback: Intl.DateTimeFormat.formatRange is the standard\n // mechanism with native field-collapse behavior, but it has no\n // knowledge of the caller's token format string.\n try {\n const fmt = new Intl.DateTimeFormat(normalizeLocaleTag(options.locale ?? 'en-US'), {});\n // Cast the interval endpoints to Date for the Intl call. Both\n // endpoints must be Temporal values that can convert to a Date;\n // for non-ZonedDateTime values we synthesize a Date via the field\n // shape (year/month/day/hour/...).\n const startDate = toJSDate(iv.start);\n const endDate = toJSDate(iv.end);\n return fmt.formatRange(startDate, endDate);\n } catch {\n // Neither path could render — surface the token-path error, since\n // the formatStr contract is the primary one.\n throw err;\n }\n }\n}\n\nexport function formatRangeToParts(\n iv: Interval,\n formatStr: string,\n options: FormatOptions = {},\n): FormattedPart[] {\n // Best-effort: returns formatToParts for the start, then a literal\n // \" – \" part, then formatToParts for the end. Doesn't currently\n // expose Intl.DateTimeFormat.formatRangeToParts's collapsed shape —\n // that would require mapping Intl's part types back to temporal-fmt's\n // token strings, which is locale-dependent and not stable across\n // engines.\n const startParts = formatToParts(iv.start as Parameters<typeof formatToParts>[0], formatStr, options);\n const endParts = formatToParts(iv.end as Parameters<typeof formatToParts>[0], formatStr, options);\n const result: FormattedPart[] = [...startParts];\n result.push({ type: 'literal', value: ' – ' });\n result.push(...endParts);\n return result;\n}\n\nfunction toJSDate(value: unknown): Date {\n const v = value as { year?: number; month?: number; day?: number; hour?: number; minute?: number; second?: number; millisecond?: number; toInstant?: () => { epochMilliseconds: number } };\n if (typeof v?.toInstant === 'function') {\n return new Date(v.toInstant().epochMilliseconds);\n }\n if (typeof v?.year === 'number' && typeof v?.month === 'number' && typeof v?.day === 'number') {\n return new Date(Date.UTC(v.year, v.month - 1, v.day, v.hour ?? 0, v.minute ?? 0, v.second ?? 0, v.millisecond ?? 0));\n }\n throw new Error(`temporal-fmt: formatRange() expected Temporal values with year/month/day, got ${typeof value}.`);\n}"],"mappings":";;;;;;;;;;;;;;;;;;AA0CO,SAAS,SAAS,OAAgB,KAAc,SAAyB,UAAoB;AAElG,QAAM,MAAM,QAAQ,OAAO,GAAG;AAC9B,MAAI,MAAM,GAAG;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,OAAO,KAAK,OAAO;AAC9B;AAeA,SAAS,cAAc,QAAiC;AACtD,SAAO,WAAW,YAAY,WAAW;AAC3C;AACA,SAAS,YAAY,QAAiC;AACpD,SAAO,WAAW,YAAY,WAAW;AAC3C;AAEO,SAAS,SAAS,IAAc,OAAyB;AAC9D,QAAM,WAAW,QAAQ,OAAO,GAAG,KAAK;AACxC,QAAM,SAAS,QAAQ,OAAO,GAAG,GAAG;AACpC,QAAM,aAAa,cAAc,GAAG,MAAM,IAAI,YAAY,IAAI,WAAW;AACzE,QAAM,YAAY,YAAY,GAAG,MAAM,IAAI,UAAU,IAAI,SAAS;AAClE,SAAO,cAAc;AACvB;AAKO,SAAS,SAAS,GAAa,GAAsB;AAC1D,SAAO,WAAW,GAAG,CAAC;AACxB;AAEO,SAAS,WAAW,GAAa,GAAsB;AAS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AG,UAAU;AAC9C,SAAO,KAAK,EAAE,MAAM,WAAW,OAAO,WAAM,CAAC;AAC7C,SAAO,KAAK,GAAG,QAAQ;AACvB,SAAO;AACT;AAEA,SAAS,SAAS,OAAsB;AACtC,QAAM,IAAI;AACV,MAAI,OAAO,GAAG,cAAc,YAAY;AACtC,WAAO,IAAI,KAAK,EAAE,UAAU,EAAE,iBAAiB;AAAA,EACjD;AACA,MAAI,OAAO,GAAG,SAAS,YAAY,OAAO,GAAG,UAAU,YAAY,OAAO,GAAG,QAAQ,UAAU;AAC7F,WAAO,IAAI,KAAK,KAAK,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAG,EAAE,KAAK,EAAE,QAAQ,GAAG,EAAE,UAAU,GAAG,EAAE,UAAU,GAAG,EAAE,eAAe,CAAC,CAAC;AAAA,EACrH;AACA,QAAM,IAAI,MAAM,iFAAiF,OAAO,KAAK,GAAG;AAClH;","names":[]}
|
|
@@ -359,26 +359,9 @@ var TOKENS = [
|
|
|
359
359
|
return intlPart(t, locale, { timeZoneName: "short" }, "timeZoneName");
|
|
360
360
|
}, "timeZoneId"]
|
|
361
361
|
];
|
|
362
|
-
var registeredTokens = /* @__PURE__ */ new Map();
|
|
363
|
-
var rebuildListeners = [];
|
|
364
|
-
function onTokenTableChange(listener) {
|
|
365
|
-
rebuildListeners.push(listener);
|
|
366
|
-
}
|
|
367
|
-
function getEffectiveTokens() {
|
|
368
|
-
const merged = new Map(TOKENS.map((t) => [t[0], t]));
|
|
369
|
-
for (const [name, entry] of registeredTokens) merged.set(name, entry);
|
|
370
|
-
return [...merged.values()];
|
|
371
|
-
}
|
|
372
|
-
function registerToken(token) {
|
|
373
|
-
registeredTokens.set(token[0], token);
|
|
374
|
-
for (const listener of rebuildListeners) listener();
|
|
375
|
-
}
|
|
376
362
|
|
|
377
363
|
export {
|
|
378
364
|
DEFAULT_LOCALE,
|
|
379
|
-
TOKENS
|
|
380
|
-
onTokenTableChange,
|
|
381
|
-
getEffectiveTokens,
|
|
382
|
-
registerToken
|
|
365
|
+
TOKENS
|
|
383
366
|
};
|
|
384
|
-
//# sourceMappingURL=chunk-
|
|
367
|
+
//# sourceMappingURL=chunk-Z245NHDT.js.map
|