@formatjs/intl-datetimeformat-calendar-japanese 1.1.6 → 1.1.7

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/index.js CHANGED
@@ -1,480 +1,3 @@
1
- // node_modules/.aspect_rules_js/temporal-utils@1.0.3/node_modules/temporal-utils/dist/errorMessages.js
2
- const expectedPositive = (entityName, num) => `Non-positive ${entityName}: ${num}`;
3
- const expectedFinite = (entityName, num) => `Non-finite ${entityName}: ${num}`;
4
- const forbiddenBigIntToNumber = (entityName) => `Cannot convert bigint to ${entityName}`;
5
- const numberOutOfRange = (entityName, val, min, max) => invalidEntity$1(entityName, val) + `; must be between ${min}-${max}`;
6
- const invalidEntity$1 = (fieldName, val) => `Invalid ${fieldName}: ${val}`;
7
- function toFiniteNumber(arg, entityName = "number") {
8
- if (typeof arg === "bigint") throw new TypeError(forbiddenBigIntToNumber(entityName));
9
- arg = Number(arg);
10
- if (!Number.isFinite(arg)) throw new RangeError(expectedFinite(entityName, arg));
11
- return arg;
12
- }
13
- function toIntegerWithTrunc(arg, entityName) {
14
- return Math.trunc(toFiniteNumber(arg, entityName)) || 0;
15
- }
16
- function toPositiveIntegerWithTruncation(arg, entityName) {
17
- return requireNumberIsPositive(toIntegerWithTrunc(arg, entityName), entityName);
18
- }
19
- function requireNumberIsPositive(num, entityName = "number") {
20
- if (num <= 0) throw new RangeError(expectedPositive(entityName, num));
21
- return num;
22
- }
23
- function constrainToRange$1(num, min, max) {
24
- return Math.min(Math.max(num, min), max);
25
- }
26
- function isObjectLike(arg) {
27
- return arg !== null && (typeof arg === "object" || typeof arg === "function");
28
- }
29
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/internal.js
30
- const invalidEntity = invalidEntity$1;
31
- const missingField = (fieldName) => `Missing ${fieldName}`;
32
- const forbiddenValueOf$1 = "Cannot use valueOf";
33
- const invalidCallingContext = "Invalid calling context";
34
- const exoticCalendarRequired = (calendarId, remedy) => `Unknown calendar ${calendarId}; might need ${remedy}`;
35
- const constrainToRange = constrainToRange$1;
36
- function throwRangeError(message) {
37
- throw new RangeError(message);
38
- }
39
- function throwTypeError(message) {
40
- throw new TypeError(message);
41
- }
42
- function clampProp(props, propName, min, max, overflow) {
43
- return clampEntity(propName, ((props, propName) => {
44
- const propVal = props[propName];
45
- return void 0 === propVal && throwTypeError(missingField(propName)), propVal;
46
- })(props, propName), min, max, overflow);
47
- }
48
- function clampEntity(entityName, num, min, max, overflow, choices) {
49
- const clamped = constrainToRange(num, min, max);
50
- return overflow && num !== clamped && throwRangeError(((entityName, val, min, max, choices) => choices ? numberOutOfRange(entityName, choices[val], choices[min], choices[max]) : numberOutOfRange(entityName, val, min, max))(entityName, num, min, max, choices)), clamped;
51
- }
52
- function memoize(generator, MapClass = Map) {
53
- const map = new MapClass();
54
- return (key, ...otherArgs) => {
55
- if (map.has(key)) return map.get(key);
56
- const val = generator(key, ...otherArgs);
57
- return map.set(key, val), val;
58
- };
59
- }
60
- const createNameDescriptors = (name) => createPropDescriptors({ name }, 1);
61
- const createPropDescriptors = (propVals, readonly) => mapProps((value) => ({
62
- value,
63
- configurable: 1,
64
- writable: !readonly
65
- }), propVals);
66
- const createStringTagDescriptors = (value) => ({ [Symbol.toStringTag]: {
67
- value,
68
- configurable: 1
69
- } });
70
- function mapProps(transformer, props) {
71
- const res = {};
72
- for (const propName in props) res[propName] = transformer(props[propName], propName);
73
- return res;
74
- }
75
- function zipPropsConst(propNames, propVal) {
76
- const res = {};
77
- for (const propName of propNames) res[propName] = propVal;
78
- return res;
79
- }
80
- function createPropGetters(propNames) {
81
- const getters = {};
82
- for (const propName of propNames) getters[propName] = (slots) => slots[propName];
83
- return getters;
84
- }
85
- function pluckProps(propNames, props, dest = Object.create(null)) {
86
- for (const propName of propNames) dest[propName] = props[propName];
87
- return dest;
88
- }
89
- function bindArgs(f, ...boundArgs) {
90
- return (...dynamicArgs) => f(...boundArgs, ...dynamicArgs);
91
- }
92
- function noop() {}
93
- function padNumber(digits, num) {
94
- return String(num).padStart(digits, "0");
95
- }
96
- const padNumber2 = /*@__PURE__*/ bindArgs(padNumber, 2);
97
- function modFloor(num, divisor) {
98
- return (num % divisor + divisor) % divisor;
99
- }
100
- function divTrunc(num, divisor) {
101
- return Math.trunc(num / divisor) || 0;
102
- }
103
- function modTrunc(num, divisor) {
104
- return num % divisor || 0;
105
- }
106
- const gregoryEraOrigins = {
107
- "bce": -1,
108
- "ce": 0
109
- };
110
- function getCalendarSlotId(calendar) {
111
- return calendar === void 0 ? "iso8601" : 0 === calendar ? "gregory" : calendar.id;
112
- }
113
- function formatMonthCode(monthCodeNumber, isLeapMonth) {
114
- return "M" + padNumber2(monthCodeNumber) + (isLeapMonth ? "L" : "");
115
- }
116
- const unitNamesAsc = /*@__PURE__*/ Object.keys({
117
- nanosecond: 0,
118
- microsecond: 1,
119
- millisecond: 2,
120
- second: 3,
121
- minute: 4,
122
- hour: 5,
123
- day: 6,
124
- week: 7,
125
- month: 8,
126
- year: 9
127
- });
128
- const milliInUtcDay = 864e5;
129
- const bigNanoInUtcDay = /*@__PURE__*/ BigInt(864e11);
130
- const timeFieldNamesAsc = /*@__PURE__*/ unitNamesAsc.slice(0, 6);
131
- const calendarDateFieldNamesAsc = [
132
- "day",
133
- "month",
134
- "year"
135
- ];
136
- function isoDateToEpochNano(isoDate) {
137
- return BigInt(isoDateToEpochDays(isoDate)) * bigNanoInUtcDay;
138
- }
139
- function isoDateToEpochDays(isoDate) {
140
- return isoPartsToEpochDays(isoDate.year, isoDate.month, isoDate.day);
141
- }
142
- function isoPartsToEpochDays(isoYear, isoMonth = 1, isoDay = 1) {
143
- const monthIndex = isoMonth - 1;
144
- return isoYear += Math.floor(monthIndex / 12), isoMonth = modFloor(monthIndex, 12), Date.UTC(isoYear % 400 - 400, isoMonth, 0) / 864e5 + 146097 * (divTrunc(isoYear, 400) + 1) + isoDay;
145
- }
146
- const isoEpochFirstLeapYear = 1972;
147
- function computeIsoMonthCodeParts(month) {
148
- return [month, 0];
149
- }
150
- function computeIsoYearMonthFieldsForMonthDay(monthCodeNumber, isLeapMonth) {
151
- if (!isLeapMonth) return {
152
- year: 1972,
153
- month: monthCodeNumber
154
- };
155
- }
156
- function computeIsoFieldsFromParts(year, month, day) {
157
- return {
158
- year,
159
- month,
160
- day
161
- };
162
- }
163
- function computeIsoDaysInMonth(year, month) {
164
- switch (month) {
165
- case 2: return computeIsoInLeapYear(year) ? 29 : 28;
166
- case 4:
167
- case 6:
168
- case 9:
169
- case 11: return 30;
170
- }
171
- return 31;
172
- }
173
- function computeIsoDaysInYear(year) {
174
- return computeIsoInLeapYear(year) ? 366 : 365;
175
- }
176
- function computeIsoInLeapYear(year) {
177
- return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
178
- }
179
- function addIsoMonths(year, month, monthDelta) {
180
- return year += divTrunc(monthDelta, 12), (month += modTrunc(monthDelta, 12)) < 1 ? (year--, month += 12) : month > 12 && (year++, month -= 12), {
181
- year,
182
- month
183
- };
184
- }
185
- function diffIsoMonthSlots(year0, month0, year1, month1) {
186
- return 12 * (year1 - year0) + month1 - month0;
187
- }
188
- function computeGregoryEraFields({ year }) {
189
- return year < 1 ? {
190
- era: "bce",
191
- eraYear: 1 - year
192
- } : {
193
- era: "ce",
194
- eraYear: year
195
- };
196
- }
197
- function validateIsoDateFields(isoInternals) {
198
- return constrainIsoDateFields(isoInternals, 1), isoInternals;
199
- }
200
- function constrainIsoDateFields(isoDate, overflow) {
201
- const { year } = isoDate;
202
- const month = clampProp(isoDate, "month", 1, 12, overflow);
203
- return {
204
- year,
205
- month,
206
- day: clampProp(isoDate, "day", 1, computeIsoDaysInMonth(year, month), overflow)
207
- };
208
- }
209
- function computeCalendarDateFields(calendar, isoDate) {
210
- return calendar ? calendar.de(isoDate) : isoDate;
211
- }
212
- function computeCalendarMonthCodeParts(calendar, year, month) {
213
- return calendar ? calendar.N(year, month) : computeIsoMonthCodeParts(month);
214
- }
215
- function computeCalendarEraFields(calendar, isoDate) {
216
- return 0 === calendar ? computeGregoryEraFields(isoDate) : calendar && calendar.h?.(isoDate) || {};
217
- }
218
- function computeCalendarMonthCode(calendar, isoDate) {
219
- const { year, month } = computeCalendarDateFields(calendar, isoDate);
220
- const [monthCodeNumber, isLeapMonth] = computeCalendarMonthCodeParts(calendar, year, month);
221
- return formatMonthCode(monthCodeNumber, isLeapMonth);
222
- }
223
- function computeCalendarInLeapYear(calendar, isoDate) {
224
- const { year } = computeCalendarDateFields(calendar, isoDate);
225
- return calendar ? calendar.q(year) : computeIsoInLeapYear(year);
226
- }
227
- const requireString = /*@__PURE__*/ bindArgs(requireType, "string");
228
- function requireType(typeName, arg, entityName = typeName) {
229
- return typeof arg !== typeName && throwTypeError(invalidEntity(entityName, arg)), arg;
230
- }
231
- function toString(arg) {
232
- return "symbol" == typeof arg && throwTypeError("Cannot convert Symbol to string"), String(arg);
233
- }
234
- function toPrimitiveWithStringHint(arg) {
235
- if (!isObjectLike(arg)) return arg;
236
- const exoticToPrimitive = arg[Symbol.toPrimitive];
237
- if (null != exoticToPrimitive) {
238
- "function" != typeof exoticToPrimitive && throwTypeError();
239
- const primitive = Reflect.apply(exoticToPrimitive, arg, ["string"]);
240
- return isObjectLike(primitive) && throwTypeError(), primitive;
241
- }
242
- return Date.prototype[Symbol.toPrimitive].call(arg, "string");
243
- }
244
- const epochNanoMax = /*@__PURE__*/ BigInt(1e8) * bigNanoInUtcDay;
245
- const epochNanoMin = /*@__PURE__*/ BigInt(-1e8) * bigNanoInUtcDay;
246
- const plainDateEpochNanoMin = epochNanoMin - bigNanoInUtcDay;
247
- function checkIsoDateInBounds(isoDate, allowPlainDateLowerEdge = 1) {
248
- const epochNano = isoDateToEpochNano(isoDate);
249
- return (epochNano < (allowPlainDateLowerEdge ? plainDateEpochNanoMin : epochNanoMin) || epochNano > epochNanoMax) && throwRangeError("Out-of-bounds date"), isoDate;
250
- }
251
- function createDateSlots(isoDate, calendar) {
252
- return pluckProps(calendarDateFieldNamesAsc, isoDate, { calendar });
253
- }
254
- ({ .../* @__PURE__ */ Object.assign({}, {
255
- era: toString,
256
- month: toPositiveIntegerWithTruncation,
257
- monthCode(monthCode, fieldName) {
258
- return requireString(toPrimitiveWithStringHint(monthCode), fieldName);
259
- },
260
- day: toPositiveIntegerWithTruncation
261
- }, /* @__PURE__ */ zipPropsConst(timeFieldNamesAsc, toIntegerWithTrunc)) });
262
- Intl.DateTimeFormat;
263
- function formatDateIsoAuto(plainDateSlots) {
264
- return formatIsoDateFields(plainDateSlots) + (plainDateSlots.calendar === void 0 ? "" : formatCalendarId(getCalendarSlotId(plainDateSlots.calendar), 0));
265
- }
266
- function formatIsoDateFields(isoDate) {
267
- return formatIsoYearMonthFields(isoDate) + "-" + padNumber2(isoDate.day);
268
- }
269
- function formatIsoYearMonthFields(isoDate) {
270
- const { year } = isoDate;
271
- return (year < 0 || year > 9999 ? getSignStr(year) + padNumber(6, Math.abs(year)) : padNumber(4, year)) + "-" + padNumber2(isoDate.month);
272
- }
273
- function formatCalendarId(calendarId, isCritical) {
274
- return "[" + (isCritical ? "!" : "") + "u-ca=" + calendarId + "]";
275
- }
276
- function getSignStr(num) {
277
- return num < 0 ? "-" : "+";
278
- }
279
- function timeRegExpStr(separatorIndex) {
280
- return `(\\d{2})(?:(:?)(\\d{2})(?:\\${separatorIndex}(\\d{2})(?:[.,](\\d{1,9}))?)?)?`;
281
- }
282
- "" + timeRegExpStr(8) + timeRegExpStr(15);
283
- "" + timeRegExpStr(2) + `(([+-])${timeRegExpStr(9)})?((?:\\[(!?)([^\\]]*)\\]){0,9})`;
284
- ({ .../* @__PURE__ */ Object.assign({}, {
285
- year: "numeric",
286
- month: "numeric",
287
- day: "numeric"
288
- }, {
289
- hour: "numeric",
290
- minute: "numeric",
291
- second: "numeric"
292
- }) });
293
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/exoticCalendars-utils.js
294
- function createGregoryAlignedCalendar(config) {
295
- const isoYearOffset = config.se || 0;
296
- function calendarYearToIsoYear(year) {
297
- return year - isoYearOffset;
298
- }
299
- function isoYearToCalendarYear(year) {
300
- return year + isoYearOffset;
301
- }
302
- return {
303
- k: config.k,
304
- re: isoEpochFirstLeapYear + isoYearOffset,
305
- je: config.je,
306
- de(isoDate) {
307
- return {
308
- ...isoDate,
309
- year: isoYearToCalendarYear(isoDate.year)
310
- };
311
- },
312
- fe(year, month, day) {
313
- return computeIsoFieldsFromParts(calendarYearToIsoYear(year), month, day);
314
- },
315
- pe(year, month, day) {
316
- return isoPartsToEpochDays(calendarYearToIsoYear(year), month, day) * milliInUtcDay;
317
- },
318
- N(_year, month) {
319
- return computeIsoMonthCodeParts(month);
320
- },
321
- u(monthCodeNumber, isLeapMonth) {
322
- const yearMonth = computeIsoYearMonthFieldsForMonthDay(monthCodeNumber, isLeapMonth);
323
- return yearMonth && {
324
- year: isoYearToCalendarYear(yearMonth.year),
325
- month: yearMonth.month
326
- };
327
- },
328
- q(year) {
329
- return computeIsoInLeapYear(calendarYearToIsoYear(year));
330
- },
331
- j() {
332
- return 12;
333
- },
334
- o(year, month) {
335
- return computeIsoDaysInMonth(calendarYearToIsoYear(year), month);
336
- },
337
- i(year) {
338
- return computeIsoDaysInYear(calendarYearToIsoYear(year));
339
- },
340
- p() {},
341
- h(isoDate) {
342
- return config.h?.(isoDate, isoYearToCalendarYear(isoDate.year)) || {};
343
- },
344
- ae(year, month, monthDelta) {
345
- const yearMonth = addIsoMonths(calendarYearToIsoYear(year), month, monthDelta);
346
- return {
347
- year: isoYearToCalendarYear(yearMonth.year),
348
- month: yearMonth.month
349
- };
350
- },
351
- ee(year0, month0, year1, month1) {
352
- return diffIsoMonthSlots(calendarYearToIsoYear(year0), month0, calendarYearToIsoYear(year1), month1);
353
- }
354
- };
355
- }
356
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/exoticCalendars.js
357
- const japaneseEraOrigins = /*@__PURE__*/ Object.assign({}, gregoryEraOrigins, {
358
- "meiji": 1867,
359
- "taisho": 1911,
360
- "showa": 1925,
361
- "heisei": 1988,
362
- "reiwa": 2018
363
- });
364
- function computeJapaneseEraFields(isoDate) {
365
- const epochDays = isoDateToEpochDays(isoDate);
366
- const era = epochDays >= 18017 ? "reiwa" : epochDays >= 6947 ? "heisei" : epochDays >= -15713 ? "showa" : epochDays >= -20974 ? "taisho" : epochDays >= -35428 ? "meiji" : void 0;
367
- return era ? {
368
- era,
369
- eraYear: isoDate.year - japaneseEraOrigins[era]
370
- } : computeGregoryEraFields(isoDate);
371
- }
372
- const japaneseMeta = ["japanese", () => createGregoryAlignedCalendar({
373
- k: japaneseEraOrigins,
374
- je: 1,
375
- h: computeJapaneseEraFields
376
- })];
377
- const getOrCreateExoticCalendar = /*@__PURE__*/ memoize((canonicalId, createExoticCalendar) => {
378
- const calendar = createExoticCalendar(canonicalId);
379
- return calendar.id = canonicalId, calendar;
380
- });
381
- function createExoticCalendarGetter(meta) {
382
- return () => getOrCreateExoticCalendar(...meta);
383
- }
384
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/apiHelpers.js
385
- const PlainDateBranding = "PlainDate";
386
- const CalendarBranding = "Calendar";
387
- function defineTemporalClass(branding, cls, getSlots, ...getterMaps) {
388
- return Object.defineProperties(cls, createNameDescriptors(branding)), Object.defineProperties(cls.prototype, createStringTagDescriptors("Temporal." + branding)), Object.defineProperties(cls.prototype, mapProps((getter) => ({
389
- get() {
390
- return getter(getSlots(this));
391
- },
392
- configurable: 1
393
- }), Object.assign({}, ...getterMaps))), cls;
394
- }
395
- const attachDebugString = "noop" === noop.name ? (instance) => {
396
- Object.defineProperty(instance, "_str_", { value: instance.toJSON() });
397
- } : noop;
398
- function invalidRecordType() {
399
- throwTypeError(invalidCallingContext);
400
- }
401
- function forbiddenValueOf() {
402
- throwTypeError(forbiddenValueOf$1);
403
- }
404
- const dateFieldGetters$1 = {
405
- era(slots) {
406
- return computeCalendarEraFields(slots.calendar, slots).era;
407
- },
408
- eraYear(slots) {
409
- return computeCalendarEraFields(slots.calendar, slots).eraYear;
410
- },
411
- year(slots) {
412
- return computeCalendarDateFields(slots.calendar, slots).year;
413
- },
414
- month(slots) {
415
- return computeCalendarDateFields(slots.calendar, slots).month;
416
- },
417
- monthCode(slots) {
418
- return computeCalendarMonthCode(slots.calendar, slots);
419
- },
420
- day(slots) {
421
- return computeCalendarDateFields(slots.calendar, slots).day;
422
- }
423
- };
424
- function createNativeGetters(shimGetters) {
425
- return createPropGetters(Object.keys(shimGetters));
426
- }
427
- const dateFieldGetters = /*@__PURE__*/ createNativeGetters(dateFieldGetters$1);
428
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/funcApi.js
429
- const PlainDateRecordBranding = `${PlainDateBranding}Record`;
430
- const CalendarRecordBranding = `${CalendarBranding}Record`;
431
- const calendarMap = /*@__PURE__*/ new WeakMap();
432
- const plainDateMap = /*@__PURE__*/ new WeakMap();
433
- function getCalendarSlots(record) {
434
- return getCalendarSlotsIfPresent(record) || invalidRecordType();
435
- }
436
- function getCalendarSlotsIfPresent(record) {
437
- return calendarMap.get(record);
438
- }
439
- function getPlainDateSlots(record) {
440
- return getPlainDateSlotsIfPresent(record) || invalidRecordType();
441
- }
442
- function getPlainDateSlotsIfPresent(record) {
443
- return plainDateMap.get(record);
444
- }
445
- function setPlainDateSlots(instance, slots) {
446
- plainDateMap.set(instance, slots);
447
- }
448
- const CalendarRecord = /*@__PURE__*/ defineTemporalClass(CalendarRecordBranding, class {
449
- toJSON() {
450
- return getCalendarRecordId(this);
451
- }
452
- valueOf() {
453
- return getCalendarRecordId(this);
454
- }
455
- });
456
- function createCalendarRecord(id, getImpl) {
457
- const instance = Object.create(CalendarRecord.prototype);
458
- return ((instance, slots) => {
459
- calendarMap.set(instance, slots);
460
- })(instance, {
461
- id,
462
- xe: getImpl
463
- }), attachDebugString(instance), instance;
464
- }
465
- function getCalendarRecordId(record) {
466
- return getCalendarSlots(record).id;
467
- }
468
- function getCalendarRecordImplCreator(record) {
469
- const getImpl = getCalendarSlots(record).xe;
470
- return getImpl || throwRangeError(exoticCalendarRequired(getCalendarRecordId(record), "getExotic or getAny")), getImpl;
471
- }
472
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/fns/Calendar.js
473
- const getJapanese = /*@__PURE__*/ createCanonicalGetter(japaneseMeta);
474
- const getOrCreateFoundRecord = /*@__PURE__*/ memoize((rawCalendarId, meta) => createCalendarRecord(rawCalendarId, createExoticCalendarGetter(meta)));
475
- function createCanonicalGetter(meta) {
476
- return () => getOrCreateFoundRecord(meta[0], meta);
477
- }
478
1
  // packages/ecma262-abstract/DateOperations.js
479
2
  const MS_PER_DAY = 864e5;
480
3
  function Day(t) {
@@ -538,75 +61,223 @@ function DateFromTime(t) {
538
61
  if (mft === 11) return dwy - 333 - leap;
539
62
  throw new Error("Invalid time");
540
63
  }
541
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/root.js
542
- const NativeTemporal = globalThis.Temporal;
543
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/funcApi-native.js
544
- function refineNativeCalendarArgMaybe(calendarRecord) {
545
- if (void 0 !== calendarRecord) return getValidatedCalendarId(calendarRecord);
546
- }
547
- function getValidatedCalendarId(record) {
548
- return getCalendarRecordImplCreator(record), getCalendarRecordId(record);
549
- }
550
- const getNativePlainDate = getPlainDateSlots;
551
- const NativePlainDateRecord = /*@__PURE__*/ defineTemporalClass(PlainDateRecordBranding, class {
552
- get calendarId() {
553
- return getNativePlainDate(this).calendarId;
64
+ // packages/ecma402-abstract/Calendar/Arithmetic.js
65
+ const monthStarts = [
66
+ 0,
67
+ 31,
68
+ 59,
69
+ 90,
70
+ 120,
71
+ 151,
72
+ 181,
73
+ 212,
74
+ 243,
75
+ 273,
76
+ 304,
77
+ 334
78
+ ];
79
+ const mod = (value, divisor) => value - Math.floor(value / divisor) * divisor;
80
+ function integer(value) {
81
+ if (!Number.isSafeInteger(value)) throw new RangeError("Expected safe integer");
82
+ return value;
83
+ }
84
+ function HebrewLeapYear(year) {
85
+ return mod(7 * year + 1, 19) < 7;
86
+ }
87
+ function HebrewElapsedMonths(year) {
88
+ return Math.floor((235 * year - 234) / 19);
89
+ }
90
+ function hebrewDelay(year) {
91
+ const months = HebrewElapsedMonths(year);
92
+ const day = 29 * months + Math.floor((12084 + 13753 * months) / 25920);
93
+ return day + Number(mod(3 * (day + 1), 7) < 3);
94
+ }
95
+ function IsISOCalendar(calendar) {
96
+ return [
97
+ "iso8601",
98
+ "gregory",
99
+ "buddhist",
100
+ "japanese",
101
+ "roc"
102
+ ].includes(calendar);
103
+ }
104
+ function CalendarISOYear(calendar, year) {
105
+ return year + (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0);
106
+ }
107
+ function ArithmeticCalendarStartOfYear(calendar, year) {
108
+ if (IsISOCalendar(calendar)) return DayFromYear(CalendarISOYear(calendar, year));
109
+ switch (calendar) {
110
+ case "coptic": return -615923 + 365 * year + Math.floor(year / 4);
111
+ case "ethiopic": return -716732 + 365 * year + Math.floor(year / 4);
112
+ case "ethioaa": {
113
+ const value = year - 5500;
114
+ return -716732 + 365 * value + Math.floor(value / 4);
115
+ }
116
+ case "indian": return DayFromYear(year + 78) + 80;
117
+ case "islamic-civil":
118
+ case "islamic-tbla": return -492148 - Number(calendar === "islamic-tbla") + 354 * (year - 1) + Math.floor((3 + 11 * year) / 30);
119
+ case "persian": return -492268 + 365 * (year - 1) + Math.floor((8 * year + 21) / 33);
554
120
  }
555
- toJSON() {
556
- return getNativePlainDate(this).toJSON();
121
+ const present = hebrewDelay(year);
122
+ return -2092590 + present + (hebrewDelay(year + 1) - present === 356 ? 2 : present - hebrewDelay(year - 1) === 382 ? 1 : 0);
123
+ }
124
+ function ArithmeticCalendarMonthsInYear(calendar, year) {
125
+ return [
126
+ "coptic",
127
+ "ethiopic",
128
+ "ethioaa"
129
+ ].includes(calendar) || calendar === "hebrew" && HebrewLeapYear(year) ? 13 : 12;
130
+ }
131
+ function ArithmeticCalendarDaysInMonth(calendar, year, month) {
132
+ const count = ArithmeticCalendarMonthsInYear(calendar, year);
133
+ if (integer(month) < 1 || month > count) throw new RangeError("Invalid calendar month");
134
+ if (IsISOCalendar(calendar)) return month === 12 ? 31 : monthStarts[month] - monthStarts[month - 1] + Number(month === 2 && DaysInYear(CalendarISOYear(calendar, year)) === 366);
135
+ const length = ArithmeticCalendarStartOfYear(calendar, year + 1) - ArithmeticCalendarStartOfYear(calendar, year);
136
+ if ([
137
+ "coptic",
138
+ "ethiopic",
139
+ "ethioaa"
140
+ ].includes(calendar)) return month === 13 ? length - 360 : 30;
141
+ if (calendar === "indian") return month === 1 ? 30 + Number(DaysInYear(year + 78) === 366) : month <= 6 ? 31 : 30;
142
+ if (calendar === "islamic-civil" || calendar === "islamic-tbla") return month % 2 === 1 || month === 12 && length === 355 ? 30 : 29;
143
+ if (calendar === "persian") return month <= 6 ? 31 : month < 12 ? 30 : length - 336;
144
+ const code = month + Number(!HebrewLeapYear(year) && month >= 6);
145
+ if ([
146
+ 4,
147
+ 7,
148
+ 9,
149
+ 11,
150
+ 13
151
+ ].includes(code)) return 29;
152
+ if (code === 2) return length % 10 === 5 ? 30 : 29;
153
+ if (code === 3) return length % 10 === 3 ? 29 : 30;
154
+ return 30;
155
+ }
156
+ function ArithmeticCalendarMonthCode(calendar, year, month) {
157
+ const leap = calendar === "hebrew" && HebrewLeapYear(year);
158
+ if (leap && month === 6) return "M05L";
159
+ const code = month - Number(leap && month > 6);
160
+ return "M" + (code < 10 ? "0" : "") + code;
161
+ }
162
+ function ArithmeticCalendarFromEpochDay(calendar, epoch) {
163
+ const t = epoch * 864e5, civilYear = YearFromTime(t);
164
+ if (IsISOCalendar(calendar)) {
165
+ const year = civilYear - (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0), month = MonthFromTime(t) + 1;
166
+ return {
167
+ year,
168
+ month,
169
+ monthCode: ArithmeticCalendarMonthCode(calendar, year, month),
170
+ day: DateFromTime(t)
171
+ };
557
172
  }
558
- valueOf() {
559
- return getNativePlainDate(this).valueOf();
173
+ const jd = epoch + 2440588;
174
+ let year;
175
+ switch (calendar) {
176
+ case "coptic":
177
+ year = Math.floor((4 * (jd - 1824665) + 3) / 1461);
178
+ break;
179
+ case "ethiopic":
180
+ case "ethioaa":
181
+ year = Math.floor((4 * (jd - 1723856) + 3) / 1461) + (calendar === "ethioaa" ? 5500 : 0);
182
+ break;
183
+ case "islamic-civil":
184
+ case "islamic-tbla":
185
+ year = Math.floor((30 * (jd - 1948440 + Number(calendar === "islamic-tbla")) + 10646) / 10631);
186
+ break;
187
+ case "persian":
188
+ year = 1 + Math.floor((33 * (jd - 1948320) + 3) / 12053);
189
+ break;
190
+ case "indian":
191
+ year = civilYear - 78;
192
+ break;
193
+ default: year = Math.floor((epoch + 2092590) * 492480 / 179876755) + 1;
560
194
  }
561
- }, getNativePlainDate, dateFieldGetters);
562
- function createNativePlainDateRecord(native) {
563
- const instance = Object.create(NativePlainDateRecord.prototype);
564
- return setPlainDateSlots(instance, native), attachDebugString(instance), instance;
565
- }
566
- function create$2$1(isoYear, isoMonth, isoDay, calendar) {
567
- return createNativePlainDateRecord(new NativeTemporal.PlainDate(isoYear, isoMonth, isoDay, refineNativeCalendarArgMaybe(calendar)));
568
- }
569
- function inLeapYear$1$1(record) {
570
- return getNativePlainDate(record).inLeapYear;
571
- }
572
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/funcApi-shim.js
573
- function refineShimCalendarArgMaybe(calendarRecord) {
574
- return void 0 === calendarRecord ? void 0 : getCalendarRecordImpl(calendarRecord);
575
- }
576
- function getCalendarRecordImpl(record) {
577
- return getCalendarRecordImplCreator(record)();
195
+ while (ArithmeticCalendarStartOfYear(calendar, year) > epoch) year--;
196
+ while (ArithmeticCalendarStartOfYear(calendar, year + 1) <= epoch) year++;
197
+ let month = 1, remaining = epoch - ArithmeticCalendarStartOfYear(calendar, year);
198
+ while (remaining >= ArithmeticCalendarDaysInMonth(calendar, year, month)) remaining -= ArithmeticCalendarDaysInMonth(calendar, year, month++);
199
+ return {
200
+ year,
201
+ month,
202
+ monthCode: ArithmeticCalendarMonthCode(calendar, year, month),
203
+ day: remaining + 1
204
+ };
578
205
  }
579
- const getShimPlainDateSlots = getPlainDateSlots;
580
- const ShimPlainDateRecord = /*@__PURE__*/ defineTemporalClass(PlainDateRecordBranding, class {
581
- get calendarId() {
582
- return getCalendarSlotId(getShimPlainDateSlots(this).calendar);
583
- }
584
- toJSON() {
585
- return formatDateIsoAuto(getShimPlainDateSlots(this));
586
- }
587
- valueOf() {
588
- return forbiddenValueOf();
206
+ const JapaneseEras = [
207
+ [
208
+ 18017,
209
+ "reiwa",
210
+ 2018
211
+ ],
212
+ [
213
+ 6947,
214
+ "heisei",
215
+ 1988
216
+ ],
217
+ [
218
+ -15713,
219
+ "showa",
220
+ 1925
221
+ ],
222
+ [
223
+ -20974,
224
+ "taisho",
225
+ 1911
226
+ ],
227
+ [
228
+ -35428,
229
+ "meiji",
230
+ 1867
231
+ ]
232
+ ];
233
+ function ArithmeticCalendarEra(calendar, epoch, year) {
234
+ switch (calendar) {
235
+ case "iso8601": return;
236
+ case "buddhist": return {
237
+ era: "be",
238
+ eraYear: year
239
+ };
240
+ case "coptic":
241
+ case "hebrew": return {
242
+ era: "am",
243
+ eraYear: year
244
+ };
245
+ case "ethiopic": return {
246
+ era: year > 0 ? "am" : "aa",
247
+ eraYear: year > 0 ? year : year + 5500
248
+ };
249
+ case "ethioaa": return {
250
+ era: "aa",
251
+ eraYear: year
252
+ };
253
+ case "indian": return {
254
+ era: "shaka",
255
+ eraYear: year
256
+ };
257
+ case "persian": return {
258
+ era: "ap",
259
+ eraYear: year
260
+ };
261
+ case "roc": return {
262
+ era: year > 0 ? "roc" : "broc",
263
+ eraYear: year > 0 ? year : 1 - year
264
+ };
265
+ case "islamic-civil":
266
+ case "islamic-tbla": return {
267
+ era: year > 0 ? "ah" : "bh",
268
+ eraYear: year > 0 ? year : 1 - year
269
+ };
270
+ case "japanese": for (const [start, era, offset] of JapaneseEras) if (epoch >= start) return {
271
+ era,
272
+ eraYear: year - offset
273
+ };
589
274
  }
590
- }, getShimPlainDateSlots, dateFieldGetters$1);
591
- function createShimPlainDateRecord(slots) {
592
- const instance = Object.create(ShimPlainDateRecord.prototype);
593
- return setPlainDateSlots(instance, slots), attachDebugString(instance), instance;
594
- }
595
- function create$2(isoYear, isoMonth, isoDay, calendar) {
596
- return createShimPlainDateRecord(createDateSlots(checkIsoDateInBounds(validateIsoDateFields(mapProps(toIntegerWithTrunc, {
597
- year: isoYear,
598
- month: isoMonth,
599
- day: isoDay
600
- }))), refineShimCalendarArgMaybe(calendar)));
601
- }
602
- function inLeapYear$1(record) {
603
- const slots = getShimPlainDateSlots(record);
604
- return computeCalendarInLeapYear(slots.calendar, slots);
275
+ return {
276
+ era: year > 0 ? "ce" : "bce",
277
+ eraYear: year > 0 ? year : 1 - year
278
+ };
605
279
  }
606
- // node_modules/.aspect_rules_js/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/fns/PlainDate.js
607
- const create = NativeTemporal ? create$2$1 : create$2;
608
- const inLeapYear = NativeTemporal ? inLeapYear$1$1 : inLeapYear$1;
609
- // packages/intl-datetimeformat/calendars/temporal.js
280
+ // packages/intl-datetimeformat/calendars/arithmetic.js
610
281
  const eras = {
611
282
  be: "0",
612
283
  am: "1",
@@ -626,19 +297,21 @@ const eras = {
626
297
  ap: "0"
627
298
  };
628
299
  /**
629
- * Adapt Temporal calendar fields to CLDR era keys and month-name indices.
300
+ * Adapt shared calendar fields to CLDR era keys and month-name indices.
630
301
  * This is an implementation helper for ECMA-402 ToLocalTime, not a spec AO.
631
302
  * https://tc39.es/ecma402/#sec-tolocaltime
632
303
  * https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Elements
633
304
  */
634
- function temporalCalendar(calendar, getCalendar, hebrew = false) {
305
+ function arithmeticCalendar(calendar, hebrew = false) {
635
306
  return {
636
307
  calendar,
637
308
  dateFromTime(t) {
638
- const date = create(YearFromTime(t), MonthFromTime(t) + 1, DateFromTime(t), getCalendar());
309
+ const epochDay = Math.floor(t / 864e5);
310
+ if (!Number.isFinite(t) || epochDay < -100000001 || epochDay > 1e8) throw new RangeError("Calendar date out of range");
311
+ const date = ArithmeticCalendarFromEpochDay(calendar, epochDay);
639
312
  if (hebrew) {
640
313
  const monthCode = Number(date.monthCode.slice(1, 3));
641
- const monthNameIndex = date.monthCode === "M05L" ? 5 : monthCode === 6 && inLeapYear(date) ? 13 : monthCode >= 6 ? monthCode : monthCode - 1;
314
+ const monthNameIndex = date.monthCode === "M05L" ? 5 : monthCode === 6 && ArithmeticCalendarMonthsInYear(calendar, date.year) === 13 ? 13 : monthCode >= 6 ? monthCode : monthCode - 1;
642
315
  return {
643
316
  era: "0",
644
317
  year: date.year,
@@ -647,9 +320,10 @@ function temporalCalendar(calendar, getCalendar, hebrew = false) {
647
320
  day: date.day
648
321
  };
649
322
  }
323
+ const era = ArithmeticCalendarEra(calendar, epochDay, date.year);
650
324
  return {
651
- era: eras[date.era],
652
- year: date.eraYear ?? date.year,
325
+ era: eras[era.era],
326
+ year: era?.eraYear ?? date.year,
653
327
  month: date.month - 1,
654
328
  day: date.day
655
329
  };
@@ -657,7 +331,7 @@ function temporalCalendar(calendar, getCalendar, hebrew = false) {
657
331
  };
658
332
  }
659
333
  // packages/intl-datetimeformat/calendars/implementations/japanese.js
660
- const data = temporalCalendar("japanese", getJapanese);
334
+ const data = arithmeticCalendar("japanese");
661
335
  // packages/intl-datetimeformat/register-calendar-data.ts
662
336
  /** Register after installation, or queue until the polyfill is installed. */
663
337
  function registerCalendarData(...data) {