@day-kit/date-engine 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +9 -2
- package/dist/create-temporal-engine-CJDDY96Y.js +451 -0
- package/dist/create-temporal-engine-CJDDY96Y.js.map +1 -0
- package/dist/date-engine-CaLe_SPQ.d.ts +235 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/instant-h91-6kZL.js +169 -0
- package/dist/instant-h91-6kZL.js.map +1 -0
- package/dist/temporal-gregorian.d.ts +6 -0
- package/dist/temporal-gregorian.js +16 -0
- package/dist/temporal-gregorian.js.map +1 -0
- package/dist/temporal.d.ts +6 -0
- package/dist/temporal.js +16 -0
- package/dist/temporal.js.map +1 -0
- package/package.json +52 -3
- package/src/contracts/calendar-system.ts +48 -0
- package/src/contracts/date-engine.ts +140 -0
- package/src/contracts/date-formatter.ts +47 -0
- package/src/contracts/date-types.ts +144 -0
- package/src/contracts/errors.ts +104 -0
- package/src/formatting/date-style-fallback.ts +27 -0
- package/src/formatting/intl-formatters.ts +138 -0
- package/src/formatting/locale-info.ts +73 -0
- package/src/index.ts +72 -0
- package/src/operations/instant.ts +49 -0
- package/src/operations/interval.ts +45 -0
- package/src/temporal/create-temporal-engine.ts +437 -0
- package/src/temporal/full-engine.ts +11 -0
- package/src/temporal/gregorian-engine.ts +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 day-kit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @day-kit/date-engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Internal date-engine contracts and the Temporal-backed implementation used by
|
|
4
|
+
[`@day-kit/core`](https://github.com/lorof/day-kit/tree/main/packages/core#readme). It is installed as a dependency of core.
|
|
5
|
+
|
|
6
|
+
Do not depend on it directly: import engines from `@day-kit/core/temporal` or
|
|
7
|
+
`@day-kit/core/temporal-gregorian`. Its API may change in any release. See
|
|
8
|
+
[docs/date-engine.md](https://github.com/lorof/day-kit/blob/main/docs/date-engine.md) for the design.
|
|
9
|
+
|
|
10
|
+
MIT
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { S as knownCalendarSystems, _ as InvalidCalendarFieldsError, a as instantFromEpochMilliseconds, b as NonexistentLocalTimeError, d as AmbiguousLocalTimeError, g as FormattingNotSupportedError, h as DateRangeError, m as CalendarSystemNotSupportedError, s as maxEpochMilliseconds, u as weekdayFromIsoNumber, x as isKnownCalendarSystem, y as InvalidTimeZoneError } from "./instant-h91-6kZL.js";
|
|
2
|
+
// src/formatting/date-style-fallback.ts
|
|
3
|
+
/** Component options equivalent to each `dateStyle`, used when a runtime lacks the style pattern. */
|
|
4
|
+
const dateStyleComponents = {
|
|
5
|
+
full: {
|
|
6
|
+
weekday: "long",
|
|
7
|
+
year: "numeric",
|
|
8
|
+
month: "long",
|
|
9
|
+
day: "numeric"
|
|
10
|
+
},
|
|
11
|
+
long: {
|
|
12
|
+
year: "numeric",
|
|
13
|
+
month: "long",
|
|
14
|
+
day: "numeric"
|
|
15
|
+
},
|
|
16
|
+
medium: {
|
|
17
|
+
year: "numeric",
|
|
18
|
+
month: "short",
|
|
19
|
+
day: "numeric"
|
|
20
|
+
},
|
|
21
|
+
short: {
|
|
22
|
+
year: "numeric",
|
|
23
|
+
month: "numeric",
|
|
24
|
+
day: "numeric"
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const timePartTypes = /* @__PURE__ */ new Set([
|
|
28
|
+
"hour",
|
|
29
|
+
"minute",
|
|
30
|
+
"second",
|
|
31
|
+
"dayPeriod"
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Whether a date-only format produced time parts: the runtime fell back to a generic pattern
|
|
35
|
+
* (observed in Chromium for `he` + `hebrew` + `dateStyle`, which prints "57870617 12:00 PM").
|
|
36
|
+
*/
|
|
37
|
+
function hasUnexpectedTimeParts(parts) {
|
|
38
|
+
return parts.some((part) => timePartTypes.has(part.type));
|
|
39
|
+
}
|
|
40
|
+
/** Replaces `dateStyle` with equivalent component options; other options are kept. */
|
|
41
|
+
function withoutDateStyle(options) {
|
|
42
|
+
const { dateStyle, ...rest } = options;
|
|
43
|
+
return dateStyle === void 0 ? options : {
|
|
44
|
+
...dateStyleComponents[dateStyle],
|
|
45
|
+
...rest
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// src/formatting/intl-formatters.ts
|
|
49
|
+
const maxCachedFormatters = 256;
|
|
50
|
+
/** A fixed date used to validate formatter patterns. */
|
|
51
|
+
const probeDate = new Date(Date.UTC(2024, 0, 15, 12));
|
|
52
|
+
/**
|
|
53
|
+
* Noon UTC of an ISO date. Formatting a calendar date at noon UTC with `timeZone: 'UTC'`
|
|
54
|
+
* makes labels independent of the configured time zone, including skipped civil days.
|
|
55
|
+
*/
|
|
56
|
+
function isoNoonUtc(iso) {
|
|
57
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
58
|
+
date.setUTCFullYear(iso.year, iso.month - 1, iso.day);
|
|
59
|
+
date.setUTCHours(12, 0, 0, 0);
|
|
60
|
+
return date;
|
|
61
|
+
}
|
|
62
|
+
function stableKey(value) {
|
|
63
|
+
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b, "en"));
|
|
64
|
+
return JSON.stringify(entries);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates cached Intl formatters bound to an engine.
|
|
68
|
+
* Throws `FormattingNotSupportedError` when Intl cannot format the requested calendar:
|
|
69
|
+
* labels of another calendar are never shown as if they belonged to it.
|
|
70
|
+
*/
|
|
71
|
+
function createIntlFormatters(host) {
|
|
72
|
+
const cache = /* @__PURE__ */ new Map();
|
|
73
|
+
const support = /* @__PURE__ */ new Map();
|
|
74
|
+
function getDateTimeFormat(locale, options) {
|
|
75
|
+
const key = `${locale ?? ""}|${stableKey(options)}`;
|
|
76
|
+
const cached = cache.get(key);
|
|
77
|
+
if (cached !== void 0) return cached;
|
|
78
|
+
const format = new Intl.DateTimeFormat(locale, options);
|
|
79
|
+
const resolvedCalendar = format.resolvedOptions().calendar;
|
|
80
|
+
if (resolvedCalendar !== options.calendar) throw new FormattingNotSupportedError(`Intl.DateTimeFormat in this runtime cannot format the "${options.calendar}" calendar (it resolved to "${resolvedCalendar}").`);
|
|
81
|
+
if (cache.size >= maxCachedFormatters) cache.clear();
|
|
82
|
+
cache.set(key, format);
|
|
83
|
+
return format;
|
|
84
|
+
}
|
|
85
|
+
function resolvedInfo(format, calendarSystem) {
|
|
86
|
+
const resolved = format.resolvedOptions();
|
|
87
|
+
return {
|
|
88
|
+
locale: resolved.locale,
|
|
89
|
+
calendarSystem,
|
|
90
|
+
numberingSystem: resolved.numberingSystem
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
isFormattingSupported(calendarSystem) {
|
|
95
|
+
const known = support.get(calendarSystem);
|
|
96
|
+
if (known !== void 0) return known;
|
|
97
|
+
const supported = new Intl.DateTimeFormat("en", { calendar: calendarSystem }).resolvedOptions().calendar === calendarSystem;
|
|
98
|
+
support.set(calendarSystem, supported);
|
|
99
|
+
return supported;
|
|
100
|
+
},
|
|
101
|
+
createCalendarDateFormatter(options) {
|
|
102
|
+
const calendarSystem = host.requireCalendarSystem(options.calendarSystem);
|
|
103
|
+
const create = (format) => getDateTimeFormat(options.locale, {
|
|
104
|
+
...format,
|
|
105
|
+
calendar: calendarSystem,
|
|
106
|
+
timeZone: "UTC"
|
|
107
|
+
});
|
|
108
|
+
let format = create(options.format);
|
|
109
|
+
if (hasUnexpectedTimeParts(format.formatToParts(probeDate))) {
|
|
110
|
+
format = create(withoutDateStyle(options.format));
|
|
111
|
+
if (hasUnexpectedTimeParts(format.formatToParts(probeDate))) throw new FormattingNotSupportedError(`Intl.DateTimeFormat in this runtime cannot format "${calendarSystem}" dates for locale "${options.locale ?? "default"}" with ${JSON.stringify(options.format)}.`);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
resolved: resolvedInfo(format, calendarSystem),
|
|
115
|
+
format: (date) => format.format(isoNoonUtc(host.toIsoDate(date))),
|
|
116
|
+
formatToParts: (date) => format.formatToParts(isoNoonUtc(host.toIsoDate(date))),
|
|
117
|
+
formatRange: (start, end) => format.formatRange(isoNoonUtc(host.toIsoDate(start)), isoNoonUtc(host.toIsoDate(end)))
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
createInstantFormatter(options) {
|
|
121
|
+
const calendarSystem = host.requireCalendarSystem(options.calendarSystem);
|
|
122
|
+
const timeZone = host.canonicalizeTimeZone(options.timeZone);
|
|
123
|
+
const format = getDateTimeFormat(options.locale, {
|
|
124
|
+
...options.format,
|
|
125
|
+
calendar: calendarSystem,
|
|
126
|
+
timeZone
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
resolved: resolvedInfo(format, calendarSystem),
|
|
130
|
+
format: (instant) => format.format(instant),
|
|
131
|
+
formatToParts: (instant) => format.formatToParts(instant),
|
|
132
|
+
formatRange: (start, end) => format.formatRange(start, end)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// src/temporal/create-temporal-engine.ts
|
|
138
|
+
const maxTransitionsPerQuery = 1e4;
|
|
139
|
+
function toDateHandle(date) {
|
|
140
|
+
return date;
|
|
141
|
+
}
|
|
142
|
+
function fromDateHandle(date) {
|
|
143
|
+
return date;
|
|
144
|
+
}
|
|
145
|
+
function toLocalHandle(local) {
|
|
146
|
+
return local;
|
|
147
|
+
}
|
|
148
|
+
function fromLocalHandle(local) {
|
|
149
|
+
return local;
|
|
150
|
+
}
|
|
151
|
+
function sign(value) {
|
|
152
|
+
if (value < 0) return -1;
|
|
153
|
+
if (value > 0) return 1;
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
function isRangeError(error) {
|
|
157
|
+
return error instanceof RangeError;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Creates a `DateEngine` backed by a Temporal namespace.
|
|
161
|
+
* Used with `temporal-polyfill/full/implementation` and `temporal-polyfill/implementation`;
|
|
162
|
+
* the conformance suite also runs it against native Temporal to prepare the migration.
|
|
163
|
+
*/
|
|
164
|
+
function createTemporalEngine(config) {
|
|
165
|
+
const { Temporal: T, name } = config;
|
|
166
|
+
let supported;
|
|
167
|
+
let supportedSet;
|
|
168
|
+
const canonicalTimeZones = /* @__PURE__ */ new Map();
|
|
169
|
+
function probeCalendarSystems() {
|
|
170
|
+
const result = [];
|
|
171
|
+
const reference = T.PlainDate.from({
|
|
172
|
+
year: 2e3,
|
|
173
|
+
month: 1,
|
|
174
|
+
day: 1
|
|
175
|
+
});
|
|
176
|
+
for (const calendarSystem of knownCalendarSystems) try {
|
|
177
|
+
const converted = reference.withCalendar(calendarSystem);
|
|
178
|
+
if (converted.monthCode.length > 0 && converted.calendarId === calendarSystem) result.push(calendarSystem);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (!isRangeError(error)) throw error;
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
function getSupported() {
|
|
185
|
+
supported ??= probeCalendarSystems();
|
|
186
|
+
return supported;
|
|
187
|
+
}
|
|
188
|
+
function isSupported(calendarSystem) {
|
|
189
|
+
supportedSet ??= new Set(getSupported());
|
|
190
|
+
return supportedSet.has(calendarSystem);
|
|
191
|
+
}
|
|
192
|
+
function requireCalendarSystem(calendarSystem) {
|
|
193
|
+
if (isSupported(calendarSystem)) return calendarSystem;
|
|
194
|
+
throw new CalendarSystemNotSupportedError(calendarSystem, name, getSupported());
|
|
195
|
+
}
|
|
196
|
+
function canonicalizeTimeZone(timeZone) {
|
|
197
|
+
const cached = canonicalTimeZones.get(timeZone);
|
|
198
|
+
if (cached !== void 0) return cached;
|
|
199
|
+
try {
|
|
200
|
+
const canonical = T.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(timeZone).timeZoneId;
|
|
201
|
+
canonicalTimeZones.set(timeZone, canonical);
|
|
202
|
+
return canonical;
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw new InvalidTimeZoneError(timeZone, { cause: error });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function zoned(instant, timeZone) {
|
|
208
|
+
try {
|
|
209
|
+
return T.Instant.fromEpochMilliseconds(instant).toZonedDateTimeISO(timeZone);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (isRangeError(error)) {
|
|
212
|
+
canonicalizeTimeZone(timeZone);
|
|
213
|
+
throw new DateRangeError(`Instant ${instant} is outside the supported range.`, { cause: error });
|
|
214
|
+
}
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function toInstant(epochMilliseconds) {
|
|
219
|
+
return instantFromEpochMilliseconds(epochMilliseconds);
|
|
220
|
+
}
|
|
221
|
+
function guardRange(operation, compute) {
|
|
222
|
+
try {
|
|
223
|
+
return compute();
|
|
224
|
+
} catch (error) {
|
|
225
|
+
if (isRangeError(error)) throw new DateRangeError(`${operation} produced a date outside the supported range.`, { cause: error });
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function guardFields(compute) {
|
|
230
|
+
try {
|
|
231
|
+
return compute();
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if (isRangeError(error) || error instanceof TypeError) throw new InvalidCalendarFieldsError(error.message, { cause: error });
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function calendarOf(date) {
|
|
238
|
+
const id = date.calendarId;
|
|
239
|
+
if (isKnownCalendarSystem(id)) return id;
|
|
240
|
+
throw new CalendarSystemNotSupportedError(id, name, getSupported());
|
|
241
|
+
}
|
|
242
|
+
function startOfWeek(date, weekStartsOn) {
|
|
243
|
+
const daysInWeek = date.daysInWeek;
|
|
244
|
+
const offset = (weekdayFromIsoNumber(date.dayOfWeek) - weekStartsOn + daysInWeek) % daysInWeek;
|
|
245
|
+
return guardRange("startOfWeek", () => date.subtract({ days: offset }));
|
|
246
|
+
}
|
|
247
|
+
function startOfMonth(date) {
|
|
248
|
+
return date.with({ day: 1 });
|
|
249
|
+
}
|
|
250
|
+
function startOfYear(date) {
|
|
251
|
+
return date.with({
|
|
252
|
+
month: 1,
|
|
253
|
+
day: 1
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function period(unit, start, end) {
|
|
257
|
+
return {
|
|
258
|
+
unit,
|
|
259
|
+
start: toDateHandle(start),
|
|
260
|
+
end: toDateHandle(end)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const formatters = createIntlFormatters({
|
|
264
|
+
name,
|
|
265
|
+
requireCalendarSystem,
|
|
266
|
+
canonicalizeTimeZone,
|
|
267
|
+
toIsoDate: (date) => {
|
|
268
|
+
const plain = fromDateHandle(date).withCalendar("iso8601");
|
|
269
|
+
return {
|
|
270
|
+
year: plain.year,
|
|
271
|
+
month: plain.month,
|
|
272
|
+
day: plain.day
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
const engine = {
|
|
277
|
+
name,
|
|
278
|
+
getSupportedCalendarSystems: getSupported,
|
|
279
|
+
isCalendarSystemSupported: isSupported,
|
|
280
|
+
requireCalendarSystem,
|
|
281
|
+
isFormattingSupported: (calendarSystem) => isSupported(calendarSystem) && formatters.isFormattingSupported(calendarSystem),
|
|
282
|
+
canonicalizeTimeZone,
|
|
283
|
+
now: () => toInstant(T.Now.instant().epochMilliseconds),
|
|
284
|
+
toCalendarDate(instant, timeZone, calendarSystem) {
|
|
285
|
+
const calendar = requireCalendarSystem(calendarSystem);
|
|
286
|
+
return toDateHandle(zoned(instant, timeZone).toPlainDate().withCalendar(calendar));
|
|
287
|
+
},
|
|
288
|
+
getDayStart(date, timeZone) {
|
|
289
|
+
const plain = fromDateHandle(date);
|
|
290
|
+
const start = guardRange("getDayStart", () => plain.toZonedDateTime({ timeZone }));
|
|
291
|
+
const startDate = start.toPlainDate();
|
|
292
|
+
return {
|
|
293
|
+
instant: toInstant(start.epochMilliseconds),
|
|
294
|
+
isSkipped: !startDate.equals(plain)
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
toZonedFields(instant, timeZone, calendarSystem) {
|
|
298
|
+
const calendar = requireCalendarSystem(calendarSystem);
|
|
299
|
+
const value = zoned(instant, timeZone).withCalendar(calendar);
|
|
300
|
+
return {
|
|
301
|
+
date: toDateHandle(value.toPlainDate()),
|
|
302
|
+
time: {
|
|
303
|
+
hour: value.hour,
|
|
304
|
+
minute: value.minute,
|
|
305
|
+
second: value.second,
|
|
306
|
+
millisecond: value.millisecond
|
|
307
|
+
},
|
|
308
|
+
offsetMilliseconds: value.offsetNanoseconds / 1e6
|
|
309
|
+
};
|
|
310
|
+
},
|
|
311
|
+
getOffsetMilliseconds: (instant, timeZone) => zoned(instant, timeZone).offsetNanoseconds / 1e6,
|
|
312
|
+
createDate(input, calendarSystem, overflow = "reject") {
|
|
313
|
+
const calendar = requireCalendarSystem(calendarSystem);
|
|
314
|
+
return toDateHandle(guardFields(() => T.PlainDate.from({
|
|
315
|
+
...input,
|
|
316
|
+
calendar
|
|
317
|
+
}, { overflow })));
|
|
318
|
+
},
|
|
319
|
+
fromIsoDate(iso, calendarSystem) {
|
|
320
|
+
const calendar = requireCalendarSystem(calendarSystem);
|
|
321
|
+
return toDateHandle(guardFields(() => T.PlainDate.from({
|
|
322
|
+
year: iso.year,
|
|
323
|
+
month: iso.month,
|
|
324
|
+
day: iso.day
|
|
325
|
+
}, { overflow: "reject" }).withCalendar(calendar)));
|
|
326
|
+
},
|
|
327
|
+
toIsoDate(date) {
|
|
328
|
+
const plain = fromDateHandle(date).withCalendar("iso8601");
|
|
329
|
+
return {
|
|
330
|
+
year: plain.year,
|
|
331
|
+
month: plain.month,
|
|
332
|
+
day: plain.day
|
|
333
|
+
};
|
|
334
|
+
},
|
|
335
|
+
withCalendar: (date, calendarSystem) => toDateHandle(fromDateHandle(date).withCalendar(requireCalendarSystem(calendarSystem))),
|
|
336
|
+
getCalendarSystem: (date) => calendarOf(fromDateHandle(date)),
|
|
337
|
+
toKey(date) {
|
|
338
|
+
const plain = fromDateHandle(date);
|
|
339
|
+
return `${plain.calendarId}:${plain.toString({ calendarName: "never" })}`;
|
|
340
|
+
},
|
|
341
|
+
getDateFields(date) {
|
|
342
|
+
const plain = fromDateHandle(date);
|
|
343
|
+
return {
|
|
344
|
+
calendarSystem: calendarOf(plain),
|
|
345
|
+
year: plain.year,
|
|
346
|
+
month: plain.month,
|
|
347
|
+
monthCode: plain.monthCode,
|
|
348
|
+
day: plain.day,
|
|
349
|
+
dayOfWeek: weekdayFromIsoNumber(plain.dayOfWeek),
|
|
350
|
+
dayOfYear: plain.dayOfYear,
|
|
351
|
+
daysInWeek: plain.daysInWeek,
|
|
352
|
+
daysInMonth: plain.daysInMonth,
|
|
353
|
+
daysInYear: plain.daysInYear,
|
|
354
|
+
monthsInYear: plain.monthsInYear,
|
|
355
|
+
inLeapYear: plain.inLeapYear,
|
|
356
|
+
...plain.era === void 0 ? {} : { era: plain.era },
|
|
357
|
+
...plain.eraYear === void 0 ? {} : { eraYear: plain.eraYear },
|
|
358
|
+
...plain.weekOfYear === void 0 ? {} : { weekOfYear: plain.weekOfYear },
|
|
359
|
+
...plain.yearOfWeek === void 0 ? {} : { yearOfWeek: plain.yearOfWeek }
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
getIsoWeek(date) {
|
|
363
|
+
const iso = fromDateHandle(date).withCalendar("iso8601");
|
|
364
|
+
const { weekOfYear, yearOfWeek } = iso;
|
|
365
|
+
if (weekOfYear === void 0 || yearOfWeek === void 0) throw new DateRangeError(`ISO week is not defined for ${iso.toString()}.`);
|
|
366
|
+
return {
|
|
367
|
+
week: weekOfYear,
|
|
368
|
+
year: yearOfWeek
|
|
369
|
+
};
|
|
370
|
+
},
|
|
371
|
+
add: (date, duration, overflow = "constrain") => toDateHandle(guardRange("add", () => fromDateHandle(date).add(duration, { overflow }))),
|
|
372
|
+
with: (date, change, overflow = "constrain") => toDateHandle(guardFields(() => fromDateHandle(date).with(change, { overflow }))),
|
|
373
|
+
until(from, to, unit) {
|
|
374
|
+
const duration = fromDateHandle(from).until(fromDateHandle(to), { largestUnit: unit });
|
|
375
|
+
return {
|
|
376
|
+
days: duration.days,
|
|
377
|
+
months: duration.months,
|
|
378
|
+
years: duration.years
|
|
379
|
+
}[unit];
|
|
380
|
+
},
|
|
381
|
+
compare: (a, b) => sign(T.PlainDate.compare(fromDateHandle(a), fromDateHandle(b))),
|
|
382
|
+
equals: (a, b) => fromDateHandle(a).equals(fromDateHandle(b)),
|
|
383
|
+
startOfWeek: (date, weekStartsOn) => toDateHandle(startOfWeek(fromDateHandle(date), weekStartsOn)),
|
|
384
|
+
startOfMonth: (date) => toDateHandle(startOfMonth(fromDateHandle(date))),
|
|
385
|
+
startOfYear: (date) => toDateHandle(startOfYear(fromDateHandle(date))),
|
|
386
|
+
getPeriod(date, unit) {
|
|
387
|
+
const plain = fromDateHandle(date);
|
|
388
|
+
if (unit === "day") return period(unit, plain, guardRange("getPeriod", () => plain.add({ days: 1 })));
|
|
389
|
+
if (unit === "month") {
|
|
390
|
+
const start = startOfMonth(plain);
|
|
391
|
+
return period(unit, start, guardRange("getPeriod", () => start.add({ months: 1 })));
|
|
392
|
+
}
|
|
393
|
+
const start = startOfYear(plain);
|
|
394
|
+
return period(unit, start, guardRange("getPeriod", () => start.add({ years: 1 })));
|
|
395
|
+
},
|
|
396
|
+
getWeekPeriod(date, weekStartsOn) {
|
|
397
|
+
const start = startOfWeek(fromDateHandle(date), weekStartsOn);
|
|
398
|
+
return period("week", start, guardRange("getWeekPeriod", () => start.add({ days: start.daysInWeek })));
|
|
399
|
+
},
|
|
400
|
+
getMonthsOfYear(date) {
|
|
401
|
+
const first = startOfYear(fromDateHandle(date));
|
|
402
|
+
const nextYear = guardRange("getMonthsOfYear", () => first.add({ years: 1 }));
|
|
403
|
+
const months = [];
|
|
404
|
+
for (let month = first; T.PlainDate.compare(month, nextYear) < 0; month = month.add({ months: 1 })) months.push(toDateHandle(month));
|
|
405
|
+
return months;
|
|
406
|
+
},
|
|
407
|
+
createLocalDateTime: (date, time) => toLocalHandle(guardFields(() => fromDateHandle(date).toPlainDateTime(time))),
|
|
408
|
+
resolveLocalDateTime(local, timeZone) {
|
|
409
|
+
const plain = fromLocalHandle(local);
|
|
410
|
+
const earlier = guardRange("resolveLocalDateTime", () => plain.toZonedDateTime(timeZone, { disambiguation: "earlier" }));
|
|
411
|
+
const later = guardRange("resolveLocalDateTime", () => plain.toZonedDateTime(timeZone, { disambiguation: "later" }));
|
|
412
|
+
if (earlier.epochMilliseconds === later.epochMilliseconds) return {
|
|
413
|
+
kind: "unique",
|
|
414
|
+
instant: toInstant(earlier.epochMilliseconds)
|
|
415
|
+
};
|
|
416
|
+
return {
|
|
417
|
+
kind: earlier.toPlainDateTime().equals(plain) ? "repeated" : "nonexistent",
|
|
418
|
+
earlier: toInstant(earlier.epochMilliseconds),
|
|
419
|
+
later: toInstant(later.epochMilliseconds)
|
|
420
|
+
};
|
|
421
|
+
},
|
|
422
|
+
toInstant(local, timeZone, disambiguation) {
|
|
423
|
+
if (disambiguation === "reject") {
|
|
424
|
+
const resolution = engine.resolveLocalDateTime(local, timeZone);
|
|
425
|
+
const label = fromLocalHandle(local).toString({ calendarName: "never" });
|
|
426
|
+
if (resolution.kind === "nonexistent") throw new NonexistentLocalTimeError(`${label} does not exist in ${timeZone}.`);
|
|
427
|
+
if (resolution.kind === "repeated") throw new AmbiguousLocalTimeError(`${label} occurs twice in ${timeZone}.`);
|
|
428
|
+
return resolution.instant;
|
|
429
|
+
}
|
|
430
|
+
return toInstant(guardRange("toInstant", () => fromLocalHandle(local).toZonedDateTime(timeZone, { disambiguation })).epochMilliseconds);
|
|
431
|
+
},
|
|
432
|
+
getTimeZoneTransitions(timeZone, start, end) {
|
|
433
|
+
const transitions = [];
|
|
434
|
+
if (end <= start) return transitions;
|
|
435
|
+
let cursor = zoned(toInstant(Math.max(start - 1, -maxEpochMilliseconds)), timeZone);
|
|
436
|
+
while (transitions.length < maxTransitionsPerQuery) {
|
|
437
|
+
const next = cursor.getTimeZoneTransition("next");
|
|
438
|
+
if (next === null || next.epochMilliseconds >= end) break;
|
|
439
|
+
if (next.epochMilliseconds >= start) transitions.push(toInstant(next.epochMilliseconds));
|
|
440
|
+
cursor = next;
|
|
441
|
+
}
|
|
442
|
+
return transitions;
|
|
443
|
+
},
|
|
444
|
+
createCalendarDateFormatter: formatters.createCalendarDateFormatter,
|
|
445
|
+
createInstantFormatter: formatters.createInstantFormatter
|
|
446
|
+
};
|
|
447
|
+
return engine;
|
|
448
|
+
}
|
|
449
|
+
export { createTemporalEngine as t };
|
|
450
|
+
|
|
451
|
+
//# sourceMappingURL=create-temporal-engine-CJDDY96Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-temporal-engine-CJDDY96Y.js","names":[],"sources":["../src/formatting/date-style-fallback.ts","../src/formatting/intl-formatters.ts","../src/temporal/create-temporal-engine.ts"],"sourcesContent":["import type { CalendarDateFormatOptions } from '../contracts/date-formatter'\n\ntype DateStyle = NonNullable<Intl.DateTimeFormatOptions['dateStyle']>\n\n/** Component options equivalent to each `dateStyle`, used when a runtime lacks the style pattern. */\nconst dateStyleComponents: Readonly<Record<DateStyle, Intl.DateTimeFormatOptions>> = {\n full: { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' },\n long: { year: 'numeric', month: 'long', day: 'numeric' },\n medium: { year: 'numeric', month: 'short', day: 'numeric' },\n short: { year: 'numeric', month: 'numeric', day: 'numeric' },\n}\n\nconst timePartTypes: ReadonlySet<string> = new Set(['hour', 'minute', 'second', 'dayPeriod'])\n\n/**\n * Whether a date-only format produced time parts: the runtime fell back to a generic pattern\n * (observed in Chromium for `he` + `hebrew` + `dateStyle`, which prints \"57870617 12:00 PM\").\n */\nexport function hasUnexpectedTimeParts(parts: readonly Intl.DateTimeFormatPart[]): boolean {\n return parts.some((part) => timePartTypes.has(part.type))\n}\n\n/** Replaces `dateStyle` with equivalent component options; other options are kept. */\nexport function withoutDateStyle(options: CalendarDateFormatOptions): CalendarDateFormatOptions {\n const { dateStyle, ...rest } = options\n return dateStyle === undefined ? options : { ...dateStyleComponents[dateStyle], ...rest }\n}\n","import type { CalendarSystem } from '../contracts/calendar-system'\nimport type {\n CalendarDateFormatOptions,\n CalendarDateFormatter,\n CalendarDateFormatterOptions,\n InstantFormatter,\n InstantFormatterOptions,\n ResolvedFormatInfo,\n} from '../contracts/date-formatter'\nimport type { CalendarDate, IsoDateFields } from '../contracts/date-types'\nimport { FormattingNotSupportedError } from '../contracts/errors'\nimport { hasUnexpectedTimeParts, withoutDateStyle } from './date-style-fallback'\n\n/** The subset of a date engine that Intl-based formatting depends on. */\nexport interface IntlFormattingHost {\n readonly name: string\n readonly requireCalendarSystem: (calendarSystem: string) => CalendarSystem\n readonly canonicalizeTimeZone: (timeZone: string) => string\n readonly toIsoDate: (date: CalendarDate) => IsoDateFields\n}\n\nexport interface IntlFormatters {\n readonly createCalendarDateFormatter: (\n options: CalendarDateFormatterOptions,\n ) => CalendarDateFormatter\n readonly createInstantFormatter: (options: InstantFormatterOptions) => InstantFormatter\n readonly isFormattingSupported: (calendarSystem: CalendarSystem) => boolean\n}\n\nconst maxCachedFormatters = 256\n/** A fixed date used to validate formatter patterns. */\nconst probeDate = new Date(Date.UTC(2024, 0, 15, 12))\n\n/**\n * Noon UTC of an ISO date. Formatting a calendar date at noon UTC with `timeZone: 'UTC'`\n * makes labels independent of the configured time zone, including skipped civil days.\n */\nfunction isoNoonUtc(iso: IsoDateFields): Date {\n const date = new Date(0)\n date.setUTCFullYear(iso.year, iso.month - 1, iso.day)\n date.setUTCHours(12, 0, 0, 0)\n return date\n}\n\nfunction stableKey(value: object): string {\n const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b, 'en'))\n return JSON.stringify(entries)\n}\n\n/**\n * Creates cached Intl formatters bound to an engine.\n * Throws `FormattingNotSupportedError` when Intl cannot format the requested calendar:\n * labels of another calendar are never shown as if they belonged to it.\n */\nexport function createIntlFormatters(host: IntlFormattingHost): IntlFormatters {\n const cache = new Map<string, Intl.DateTimeFormat>()\n const support = new Map<CalendarSystem, boolean>()\n\n function getDateTimeFormat(\n locale: string | undefined,\n options: Intl.DateTimeFormatOptions & { calendar: CalendarSystem; timeZone: string },\n ): Intl.DateTimeFormat {\n const key = `${locale ?? ''}|${stableKey(options)}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n const format = new Intl.DateTimeFormat(locale, options)\n const resolvedCalendar = format.resolvedOptions().calendar\n if (resolvedCalendar !== options.calendar) {\n throw new FormattingNotSupportedError(\n `Intl.DateTimeFormat in this runtime cannot format the \"${options.calendar}\" calendar ` +\n `(it resolved to \"${resolvedCalendar}\").`,\n )\n }\n if (cache.size >= maxCachedFormatters) cache.clear()\n cache.set(key, format)\n return format\n }\n\n function resolvedInfo(\n format: Intl.DateTimeFormat,\n calendarSystem: CalendarSystem,\n ): ResolvedFormatInfo {\n const resolved = format.resolvedOptions()\n return { locale: resolved.locale, calendarSystem, numberingSystem: resolved.numberingSystem }\n }\n\n return {\n isFormattingSupported(calendarSystem) {\n const known = support.get(calendarSystem)\n if (known !== undefined) return known\n const supported =\n new Intl.DateTimeFormat('en', { calendar: calendarSystem }).resolvedOptions().calendar ===\n calendarSystem\n support.set(calendarSystem, supported)\n return supported\n },\n\n createCalendarDateFormatter(options) {\n const calendarSystem = host.requireCalendarSystem(options.calendarSystem)\n const create = (format: CalendarDateFormatOptions) =>\n getDateTimeFormat(options.locale, { ...format, calendar: calendarSystem, timeZone: 'UTC' })\n let format = create(options.format)\n if (hasUnexpectedTimeParts(format.formatToParts(probeDate))) {\n // The runtime lacks this style pattern for the locale and calendar: use components.\n format = create(withoutDateStyle(options.format))\n if (hasUnexpectedTimeParts(format.formatToParts(probeDate))) {\n throw new FormattingNotSupportedError(\n `Intl.DateTimeFormat in this runtime cannot format \"${calendarSystem}\" dates for ` +\n `locale \"${options.locale ?? 'default'}\" with ${JSON.stringify(options.format)}.`,\n )\n }\n }\n return {\n resolved: resolvedInfo(format, calendarSystem),\n format: (date) => format.format(isoNoonUtc(host.toIsoDate(date))),\n formatToParts: (date) => format.formatToParts(isoNoonUtc(host.toIsoDate(date))),\n formatRange: (start, end) =>\n format.formatRange(isoNoonUtc(host.toIsoDate(start)), isoNoonUtc(host.toIsoDate(end))),\n }\n },\n\n createInstantFormatter(options) {\n const calendarSystem = host.requireCalendarSystem(options.calendarSystem)\n const timeZone = host.canonicalizeTimeZone(options.timeZone)\n const format = getDateTimeFormat(options.locale, {\n ...options.format,\n calendar: calendarSystem,\n timeZone,\n })\n return {\n resolved: resolvedInfo(format, calendarSystem),\n format: (instant) => format.format(instant),\n formatToParts: (instant) => format.formatToParts(instant),\n formatRange: (start, end) => format.formatRange(start, end),\n }\n },\n }\n}\n","import type { Temporal } from 'temporal-polyfill/implementation'\nimport {\n isKnownCalendarSystem,\n knownCalendarSystems,\n type CalendarSystem,\n} from '../contracts/calendar-system'\nimport type { DateEngine } from '../contracts/date-engine'\nimport type {\n CalendarDate,\n CalendarDateFields,\n CalendarPeriod,\n Instant,\n LocalDateTime,\n Overflow,\n Weekday,\n} from '../contracts/date-types'\nimport {\n AmbiguousLocalTimeError,\n CalendarSystemNotSupportedError,\n DateRangeError,\n InvalidCalendarFieldsError,\n InvalidTimeZoneError,\n NonexistentLocalTimeError,\n} from '../contracts/errors'\nimport { createIntlFormatters } from '../formatting/intl-formatters'\nimport { weekdayFromIsoNumber } from '../formatting/locale-info'\nimport { instantFromEpochMilliseconds, maxEpochMilliseconds } from '../operations/instant'\n\n/** The Temporal namespace shape shared by polyfill entrypoints and native Temporal. */\nexport type TemporalNamespace = typeof Temporal\n\nexport interface TemporalEngineConfig {\n readonly name: string\n readonly Temporal: TemporalNamespace\n}\n\nconst maxTransitionsPerQuery = 10_000\n\n// Opaque handle conversion. This is the only place where handles meet Temporal objects.\nfunction toDateHandle(date: Temporal.PlainDate): CalendarDate {\n return date as unknown as CalendarDate\n}\n\nfunction fromDateHandle(date: CalendarDate): Temporal.PlainDate {\n return date as unknown as Temporal.PlainDate\n}\n\nfunction toLocalHandle(local: Temporal.PlainDateTime): LocalDateTime {\n return local as unknown as LocalDateTime\n}\n\nfunction fromLocalHandle(local: LocalDateTime): Temporal.PlainDateTime {\n return local as unknown as Temporal.PlainDateTime\n}\n\nfunction sign(value: number): -1 | 0 | 1 {\n if (value < 0) return -1\n if (value > 0) return 1\n return 0\n}\n\nfunction isRangeError(error: unknown): error is RangeError {\n return error instanceof RangeError\n}\n\n/**\n * Creates a `DateEngine` backed by a Temporal namespace.\n * Used with `temporal-polyfill/full/implementation` and `temporal-polyfill/implementation`;\n * the conformance suite also runs it against native Temporal to prepare the migration.\n */\nexport function createTemporalEngine(config: TemporalEngineConfig): DateEngine {\n const { Temporal: T, name } = config\n let supported: readonly CalendarSystem[] | undefined\n let supportedSet: ReadonlySet<string> | undefined\n const canonicalTimeZones = new Map<string, string>()\n\n function probeCalendarSystems(): readonly CalendarSystem[] {\n const result: CalendarSystem[] = []\n const reference = T.PlainDate.from({ year: 2000, month: 1, day: 1 })\n for (const calendarSystem of knownCalendarSystems) {\n try {\n const converted = reference.withCalendar(calendarSystem)\n // Read a calendar-specific field so that lazily loaded calendar data is exercised.\n if (converted.monthCode.length > 0 && converted.calendarId === calendarSystem) {\n result.push(calendarSystem)\n }\n } catch (error) {\n if (!isRangeError(error)) throw error\n }\n }\n return result\n }\n\n function getSupported(): readonly CalendarSystem[] {\n supported ??= probeCalendarSystems()\n return supported\n }\n\n function isSupported(calendarSystem: string): calendarSystem is CalendarSystem {\n supportedSet ??= new Set(getSupported())\n return supportedSet.has(calendarSystem)\n }\n\n function requireCalendarSystem(calendarSystem: string): CalendarSystem {\n if (isSupported(calendarSystem)) return calendarSystem\n throw new CalendarSystemNotSupportedError(calendarSystem, name, getSupported())\n }\n\n function canonicalizeTimeZone(timeZone: string): string {\n const cached = canonicalTimeZones.get(timeZone)\n if (cached !== undefined) return cached\n try {\n const canonical = T.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(timeZone).timeZoneId\n canonicalTimeZones.set(timeZone, canonical)\n return canonical\n } catch (error) {\n throw new InvalidTimeZoneError(timeZone, { cause: error })\n }\n }\n\n function zoned(instant: Instant, timeZone: string): Temporal.ZonedDateTime {\n try {\n return T.Instant.fromEpochMilliseconds(instant).toZonedDateTimeISO(timeZone)\n } catch (error) {\n if (isRangeError(error)) {\n canonicalizeTimeZone(timeZone)\n throw new DateRangeError(`Instant ${instant} is outside the supported range.`, {\n cause: error,\n })\n }\n throw error\n }\n }\n\n function toInstant(epochMilliseconds: number): Instant {\n return instantFromEpochMilliseconds(epochMilliseconds)\n }\n\n function guardRange<T>(operation: string, compute: () => T): T {\n try {\n return compute()\n } catch (error) {\n if (isRangeError(error)) {\n throw new DateRangeError(`${operation} produced a date outside the supported range.`, {\n cause: error,\n })\n }\n throw error\n }\n }\n\n function guardFields<T>(compute: () => T): T {\n try {\n return compute()\n } catch (error) {\n if (isRangeError(error) || error instanceof TypeError) {\n throw new InvalidCalendarFieldsError(error.message, { cause: error })\n }\n throw error\n }\n }\n\n function calendarOf(date: Temporal.PlainDate): CalendarSystem {\n const id = date.calendarId\n if (isKnownCalendarSystem(id)) return id\n throw new CalendarSystemNotSupportedError(id, name, getSupported())\n }\n\n function startOfWeek(date: Temporal.PlainDate, weekStartsOn: Weekday): Temporal.PlainDate {\n const daysInWeek = date.daysInWeek\n const dayOfWeek = weekdayFromIsoNumber(date.dayOfWeek)\n const offset = (dayOfWeek - weekStartsOn + daysInWeek) % daysInWeek\n return guardRange('startOfWeek', () => date.subtract({ days: offset }))\n }\n\n function startOfMonth(date: Temporal.PlainDate): Temporal.PlainDate {\n return date.with({ day: 1 })\n }\n\n function startOfYear(date: Temporal.PlainDate): Temporal.PlainDate {\n return date.with({ month: 1, day: 1 })\n }\n\n function period(\n unit: CalendarPeriod['unit'],\n start: Temporal.PlainDate,\n end: Temporal.PlainDate,\n ): CalendarPeriod {\n return { unit, start: toDateHandle(start), end: toDateHandle(end) }\n }\n\n const formatters = createIntlFormatters({\n name,\n requireCalendarSystem,\n canonicalizeTimeZone,\n toIsoDate: (date) => {\n const plain = fromDateHandle(date).withCalendar('iso8601')\n return { year: plain.year, month: plain.month, day: plain.day }\n },\n })\n\n const engine: DateEngine = {\n name,\n\n getSupportedCalendarSystems: getSupported,\n isCalendarSystemSupported: isSupported,\n requireCalendarSystem,\n isFormattingSupported: (calendarSystem) =>\n isSupported(calendarSystem) && formatters.isFormattingSupported(calendarSystem),\n canonicalizeTimeZone,\n\n now: () => toInstant(T.Now.instant().epochMilliseconds),\n\n toCalendarDate(instant, timeZone, calendarSystem) {\n const calendar = requireCalendarSystem(calendarSystem)\n return toDateHandle(zoned(instant, timeZone).toPlainDate().withCalendar(calendar))\n },\n\n getDayStart(date, timeZone) {\n const plain = fromDateHandle(date)\n const start = guardRange('getDayStart', () => plain.toZonedDateTime({ timeZone }))\n const startDate = start.toPlainDate()\n return {\n instant: toInstant(start.epochMilliseconds),\n isSkipped: !startDate.equals(plain),\n }\n },\n\n toZonedFields(instant, timeZone, calendarSystem) {\n const calendar = requireCalendarSystem(calendarSystem)\n const value = zoned(instant, timeZone).withCalendar(calendar)\n return {\n date: toDateHandle(value.toPlainDate()),\n time: {\n hour: value.hour,\n minute: value.minute,\n second: value.second,\n millisecond: value.millisecond,\n },\n offsetMilliseconds: value.offsetNanoseconds / 1e6,\n }\n },\n\n getOffsetMilliseconds: (instant, timeZone) => zoned(instant, timeZone).offsetNanoseconds / 1e6,\n\n createDate(input, calendarSystem, overflow: Overflow = 'reject') {\n const calendar = requireCalendarSystem(calendarSystem)\n return toDateHandle(guardFields(() => T.PlainDate.from({ ...input, calendar }, { overflow })))\n },\n\n fromIsoDate(iso, calendarSystem) {\n const calendar = requireCalendarSystem(calendarSystem)\n return toDateHandle(\n guardFields(() =>\n T.PlainDate.from(\n { year: iso.year, month: iso.month, day: iso.day },\n { overflow: 'reject' },\n ).withCalendar(calendar),\n ),\n )\n },\n\n toIsoDate(date) {\n const plain = fromDateHandle(date).withCalendar('iso8601')\n return { year: plain.year, month: plain.month, day: plain.day }\n },\n\n withCalendar: (date, calendarSystem) =>\n toDateHandle(fromDateHandle(date).withCalendar(requireCalendarSystem(calendarSystem))),\n\n getCalendarSystem: (date) => calendarOf(fromDateHandle(date)),\n\n toKey(date) {\n const plain = fromDateHandle(date)\n return `${plain.calendarId}:${plain.toString({ calendarName: 'never' })}`\n },\n\n getDateFields(date) {\n const plain = fromDateHandle(date)\n const fields: CalendarDateFields = {\n calendarSystem: calendarOf(plain),\n year: plain.year,\n month: plain.month,\n monthCode: plain.monthCode,\n day: plain.day,\n dayOfWeek: weekdayFromIsoNumber(plain.dayOfWeek),\n dayOfYear: plain.dayOfYear,\n daysInWeek: plain.daysInWeek,\n daysInMonth: plain.daysInMonth,\n daysInYear: plain.daysInYear,\n monthsInYear: plain.monthsInYear,\n inLeapYear: plain.inLeapYear,\n ...(plain.era === undefined ? {} : { era: plain.era }),\n ...(plain.eraYear === undefined ? {} : { eraYear: plain.eraYear }),\n ...(plain.weekOfYear === undefined ? {} : { weekOfYear: plain.weekOfYear }),\n ...(plain.yearOfWeek === undefined ? {} : { yearOfWeek: plain.yearOfWeek }),\n }\n return fields\n },\n\n getIsoWeek(date) {\n const iso = fromDateHandle(date).withCalendar('iso8601')\n const { weekOfYear, yearOfWeek } = iso\n if (weekOfYear === undefined || yearOfWeek === undefined) {\n throw new DateRangeError(`ISO week is not defined for ${iso.toString()}.`)\n }\n return { week: weekOfYear, year: yearOfWeek }\n },\n\n add: (date, duration, overflow: Overflow = 'constrain') =>\n toDateHandle(guardRange('add', () => fromDateHandle(date).add(duration, { overflow }))),\n\n with: (date, change, overflow: Overflow = 'constrain') =>\n toDateHandle(guardFields(() => fromDateHandle(date).with(change, { overflow }))),\n\n until(from, to, unit) {\n const duration = fromDateHandle(from).until(fromDateHandle(to), { largestUnit: unit })\n const byUnit = { days: duration.days, months: duration.months, years: duration.years }\n return byUnit[unit]\n },\n\n compare: (a, b) => sign(T.PlainDate.compare(fromDateHandle(a), fromDateHandle(b))),\n equals: (a, b) => fromDateHandle(a).equals(fromDateHandle(b)),\n\n startOfWeek: (date, weekStartsOn) =>\n toDateHandle(startOfWeek(fromDateHandle(date), weekStartsOn)),\n startOfMonth: (date) => toDateHandle(startOfMonth(fromDateHandle(date))),\n startOfYear: (date) => toDateHandle(startOfYear(fromDateHandle(date))),\n\n getPeriod(date, unit) {\n const plain = fromDateHandle(date)\n if (unit === 'day') {\n return period(\n unit,\n plain,\n guardRange('getPeriod', () => plain.add({ days: 1 })),\n )\n }\n if (unit === 'month') {\n const start = startOfMonth(plain)\n return period(\n unit,\n start,\n guardRange('getPeriod', () => start.add({ months: 1 })),\n )\n }\n const start = startOfYear(plain)\n return period(\n unit,\n start,\n guardRange('getPeriod', () => start.add({ years: 1 })),\n )\n },\n\n getWeekPeriod(date, weekStartsOn) {\n const start = startOfWeek(fromDateHandle(date), weekStartsOn)\n return period(\n 'week',\n start,\n guardRange('getWeekPeriod', () => start.add({ days: start.daysInWeek })),\n )\n },\n\n getMonthsOfYear(date) {\n const first = startOfYear(fromDateHandle(date))\n const nextYear = guardRange('getMonthsOfYear', () => first.add({ years: 1 }))\n const months: CalendarDate[] = []\n for (\n let month = first;\n T.PlainDate.compare(month, nextYear) < 0;\n month = month.add({ months: 1 })\n ) {\n months.push(toDateHandle(month))\n }\n return months\n },\n\n createLocalDateTime: (date, time) =>\n toLocalHandle(guardFields(() => fromDateHandle(date).toPlainDateTime(time))),\n\n resolveLocalDateTime(local, timeZone) {\n const plain = fromLocalHandle(local)\n const earlier = guardRange('resolveLocalDateTime', () =>\n plain.toZonedDateTime(timeZone, { disambiguation: 'earlier' }),\n )\n const later = guardRange('resolveLocalDateTime', () =>\n plain.toZonedDateTime(timeZone, { disambiguation: 'later' }),\n )\n if (earlier.epochMilliseconds === later.epochMilliseconds) {\n return { kind: 'unique', instant: toInstant(earlier.epochMilliseconds) }\n }\n const kind = earlier.toPlainDateTime().equals(plain) ? 'repeated' : 'nonexistent'\n return {\n kind,\n earlier: toInstant(earlier.epochMilliseconds),\n later: toInstant(later.epochMilliseconds),\n }\n },\n\n toInstant(local, timeZone, disambiguation) {\n if (disambiguation === 'reject') {\n const resolution = engine.resolveLocalDateTime(local, timeZone)\n const label = fromLocalHandle(local).toString({ calendarName: 'never' })\n if (resolution.kind === 'nonexistent') {\n throw new NonexistentLocalTimeError(`${label} does not exist in ${timeZone}.`)\n }\n if (resolution.kind === 'repeated') {\n throw new AmbiguousLocalTimeError(`${label} occurs twice in ${timeZone}.`)\n }\n return resolution.instant\n }\n const resolved = guardRange('toInstant', () =>\n fromLocalHandle(local).toZonedDateTime(timeZone, { disambiguation }),\n )\n return toInstant(resolved.epochMilliseconds)\n },\n\n getTimeZoneTransitions(timeZone, start, end) {\n const transitions: Instant[] = []\n if (end <= start) return transitions\n // Start one millisecond early so that a transition exactly at `start` is included.\n let cursor = zoned(toInstant(Math.max(start - 1, -maxEpochMilliseconds)), timeZone)\n while (transitions.length < maxTransitionsPerQuery) {\n const next = cursor.getTimeZoneTransition('next')\n if (next === null || next.epochMilliseconds >= end) break\n if (next.epochMilliseconds >= start) transitions.push(toInstant(next.epochMilliseconds))\n cursor = next\n }\n return transitions\n },\n\n createCalendarDateFormatter: formatters.createCalendarDateFormatter,\n createInstantFormatter: formatters.createInstantFormatter,\n }\n\n return engine\n}\n"],"mappings":";;;AAKA,MAAM,sBAA+E;CACnF,MAAM;EAAE,SAAS;EAAQ,MAAM;EAAW,OAAO;EAAQ,KAAK;CAAU;CACxE,MAAM;EAAE,MAAM;EAAW,OAAO;EAAQ,KAAK;CAAU;CACvD,QAAQ;EAAE,MAAM;EAAW,OAAO;EAAS,KAAK;CAAU;CAC1D,OAAO;EAAE,MAAM;EAAW,OAAO;EAAW,KAAK;CAAU;AAC7D;AAEA,MAAM,gCAAqC,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAU;AAAW,CAAC;;;;;AAM5F,SAAgB,uBAAuB,OAAoD;CACzF,OAAO,MAAM,MAAM,SAAS,cAAc,IAAI,KAAK,IAAI,CAAC;AAC1D;;AAGA,SAAgB,iBAAiB,SAA+D;CAC9F,MAAM,EAAE,WAAW,GAAG,SAAS;CAC/B,OAAO,cAAc,KAAA,IAAY,UAAU;EAAE,GAAG,oBAAoB;EAAY,GA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