@formatjs/temporal 1.0.0 → 1.1.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/polyfill-force.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal, toTemporalInstant } from "./index.js";
2
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma262-abstract/ToString.js
2
+ // packages/ecma262-abstract/ToString.js
3
3
  /**
4
4
  * https://tc39.es/ecma262/#sec-tostring
5
5
  */
@@ -9,7 +9,7 @@ function ToString(o) {
9
9
  }
10
10
  String.prototype.indexOf;
11
11
  BigInt.prototype.toString;
12
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma262-abstract/DateOperations.js
12
+ // packages/ecma262-abstract/DateOperations.js
13
13
  const MS_PER_DAY = 864e5;
14
14
  function Day(t) {
15
15
  return Math.floor(t / MS_PER_DAY);
@@ -72,7 +72,7 @@ function DateFromTime(t) {
72
72
  if (mft === 11) return dwy - 333 - leap;
73
73
  throw new Error("Invalid time");
74
74
  }
75
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/host-timezone.ts
75
+ // packages/temporal/host-timezone.ts
76
76
  const Constructor$3 = globalThis.Intl?.DateTimeFormat;
77
77
  const parts$1 = Constructor$3?.prototype.formatToParts;
78
78
  Date.now;
@@ -124,7 +124,7 @@ function createHostTimeZoneOffset(timeZone, intrinsics = {
124
124
  };
125
125
  return offsetNanoseconds;
126
126
  }
127
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/node_modules/.aspect_rules_js/@formatjs_generated+datetimeformat.calendars@0.0.0/node_modules/@formatjs_generated/datetimeformat.calendars/fallback-eras.js
127
+ // node_modules/.aspect_rules_js/@formatjs_generated+datetimeformat.calendars@0.0.0/node_modules/@formatjs_generated/datetimeformat.calendars/fallback-eras.js
128
128
  const beforeHijrah = {
129
129
  "ady": [
130
130
  "BH",
@@ -1437,7 +1437,7 @@ const beforeHijrah = {
1437
1437
  "BH"
1438
1438
  ]
1439
1439
  };
1440
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/lunisolar.ts
1440
+ // packages/temporal/lunisolar.ts
1441
1441
  const day = 86400000n;
1442
1442
  const month = day * 295305888531n / 10000000000n;
1443
1443
  const year = day * 146097n / 400n;
@@ -1484,7 +1484,7 @@ function approximateLunisolarYear(calendar, relatedYear) {
1484
1484
  leap
1485
1485
  };
1486
1486
  }
1487
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/node_modules/.aspect_rules_js/@formatjs_generated+icu.calendar@0.0.0/node_modules/@formatjs_generated/icu.calendar/host-chinese.js
1487
+ // node_modules/.aspect_rules_js/@formatjs_generated+icu.calendar@0.0.0/node_modules/@formatjs_generated/icu.calendar/host-chinese.js
1488
1488
  const ranges$2 = [{
1489
1489
  firstYear: 1900,
1490
1490
  startDay: -25537,
@@ -1694,7 +1694,7 @@ const ranges$2 = [{
1694
1694
  1453
1695
1695
  ]
1696
1696
  }];
1697
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/node_modules/.aspect_rules_js/@formatjs_generated+icu.calendar@0.0.0/node_modules/@formatjs_generated/icu.calendar/host-dangi.js
1697
+ // node_modules/.aspect_rules_js/@formatjs_generated+icu.calendar@0.0.0/node_modules/@formatjs_generated/icu.calendar/host-dangi.js
1698
1698
  const ranges$1 = [{
1699
1699
  firstYear: 1900,
1700
1700
  startDay: -25537,
@@ -1904,7 +1904,7 @@ const ranges$1 = [{
1904
1904
  1453
1905
1905
  ]
1906
1906
  }];
1907
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/host-calendar-data.ts
1907
+ // packages/temporal/host-calendar-data.ts
1908
1908
  const cache = /* @__PURE__ */ new Map();
1909
1909
  function ranges(calendar) {
1910
1910
  let result = cache.get(calendar);
@@ -1941,7 +1941,7 @@ function compactCalendarYear(calendar, year) {
1941
1941
  };
1942
1942
  }
1943
1943
  }
1944
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/host-calendar.ts
1944
+ // packages/temporal/host-calendar.ts
1945
1945
  const Constructor$2 = globalThis.Intl?.DateTimeFormat;
1946
1946
  const parts = Constructor$2?.prototype.formatToParts;
1947
1947
  const resolved = Constructor$2?.prototype.resolvedOptions;
@@ -2026,7 +2026,7 @@ function hostCalendarDate(calendar, epoch) {
2026
2026
  day: epoch - data.starts[month - 1] + 1
2027
2027
  };
2028
2028
  }
2029
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/calendar-table.ts
2029
+ // packages/temporal/calendar-table.ts
2030
2030
  function isLunisolar(calendar) {
2031
2031
  return calendar === "chinese" || calendar === "dangi";
2032
2032
  }
@@ -2047,25 +2047,21 @@ function tableMonthLength(calendar, year, month) {
2047
2047
  function tableDate(calendar, epoch) {
2048
2048
  return hostCalendarDate(calendar, epoch);
2049
2049
  }
2050
- const calendarIds = [
2051
- ...[
2052
- "iso8601",
2053
- "gregory",
2054
- "buddhist",
2055
- "japanese",
2056
- "roc",
2057
- "coptic",
2058
- "ethiopic",
2059
- "ethioaa",
2060
- "hebrew",
2061
- "indian",
2062
- "islamic-civil",
2063
- "islamic-tbla",
2064
- "persian"
2065
- ],
2066
- "chinese",
2067
- "dangi",
2068
- "islamic-umalqura"
2050
+ // packages/ecma402-abstract/Calendar/Arithmetic.js
2051
+ const arithmeticCalendars = [
2052
+ "iso8601",
2053
+ "gregory",
2054
+ "buddhist",
2055
+ "japanese",
2056
+ "roc",
2057
+ "coptic",
2058
+ "ethiopic",
2059
+ "ethioaa",
2060
+ "hebrew",
2061
+ "indian",
2062
+ "islamic-civil",
2063
+ "islamic-tbla",
2064
+ "persian"
2069
2065
  ];
2070
2066
  const monthStarts$1 = [
2071
2067
  0,
@@ -2082,41 +2078,22 @@ const monthStarts$1 = [
2082
2078
  334
2083
2079
  ];
2084
2080
  const mod = (value, divisor) => value - Math.floor(value / divisor) * divisor;
2085
- function integer(value) {
2081
+ function integer$1(value) {
2086
2082
  if (!Number.isSafeInteger(value)) throw new RangeError("Expected safe integer");
2087
2083
  return value;
2088
2084
  }
2089
- function yearCheck(year) {
2090
- if (Math.abs(integer(year)) > 4e5) throw new RangeError("Calendar year out of range");
2091
- return year;
2092
- }
2093
- function dayCheck(day) {
2094
- if (integer(day) < -100000001 || day > 1e8) throw new RangeError("Calendar date out of range");
2095
- return day;
2096
- }
2097
- function calendarCheck(calendar) {
2098
- if (!calendarIds.includes(calendar)) throw new RangeError("Unsupported calendar");
2099
- }
2100
- function overflowCheck(overflow) {
2101
- if (overflow !== "constrain" && overflow !== "reject") throw new RangeError("Invalid overflow");
2102
- }
2103
- function regulate(value, min, max, overflow) {
2104
- if (!Number.isInteger(value)) throw new RangeError("Expected finite integer");
2105
- if (overflow === "reject" && (value < min || value > max)) throw new RangeError("Calendar field out of range");
2106
- return Math.min(Math.max(value, min), max);
2107
- }
2108
- function hebrewLeap(year) {
2085
+ function HebrewLeapYear(year) {
2109
2086
  return mod(7 * year + 1, 19) < 7;
2110
2087
  }
2111
- function elapsedMonths(year) {
2088
+ function HebrewElapsedMonths(year) {
2112
2089
  return Math.floor((235 * year - 234) / 19);
2113
2090
  }
2114
2091
  function hebrewDelay(year) {
2115
- const months = elapsedMonths(year);
2092
+ const months = HebrewElapsedMonths(year);
2116
2093
  const day = 29 * months + Math.floor((12084 + 13753 * months) / 25920);
2117
2094
  return day + Number(mod(3 * (day + 1), 7) < 3);
2118
2095
  }
2119
- function isoLike(calendar) {
2096
+ function IsISOCalendar(calendar) {
2120
2097
  return [
2121
2098
  "iso8601",
2122
2099
  "gregory",
@@ -2125,13 +2102,11 @@ function isoLike(calendar) {
2125
2102
  "roc"
2126
2103
  ].includes(calendar);
2127
2104
  }
2128
- function isoYear(calendar, year) {
2105
+ function CalendarISOYear(calendar, year) {
2129
2106
  return year + (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0);
2130
2107
  }
2131
- function start(calendar, year) {
2132
- if (isLunisolar(calendar)) return tableYearStart(calendar, year);
2133
- if (calendar === "islamic-umalqura") return tableYearStart(calendar, year) ?? start("islamic-civil", year);
2134
- if (isoLike(calendar)) return DayFromYear(isoYear(calendar, year));
2108
+ function ArithmeticCalendarStartOfYear(calendar, year) {
2109
+ if (IsISOCalendar(calendar)) return DayFromYear(CalendarISOYear(calendar, year));
2135
2110
  switch (calendar) {
2136
2111
  case "coptic": return -615923 + 365 * year + Math.floor(year / 4);
2137
2112
  case "ethiopic": return -716732 + 365 * year + Math.floor(year / 4);
@@ -2147,23 +2122,18 @@ function start(calendar, year) {
2147
2122
  const present = hebrewDelay(year);
2148
2123
  return -2092590 + present + (hebrewDelay(year + 1) - present === 356 ? 2 : present - hebrewDelay(year - 1) === 382 ? 1 : 0);
2149
2124
  }
2150
- function monthsInYear(calendar, year) {
2151
- calendarCheck(calendar);
2152
- yearCheck(year);
2153
- if (isLunisolar(calendar)) return tableLeapMonth(calendar, year) ? 13 : 12;
2125
+ function ArithmeticCalendarMonthsInYear(calendar, year) {
2154
2126
  return [
2155
2127
  "coptic",
2156
2128
  "ethiopic",
2157
2129
  "ethioaa"
2158
- ].includes(calendar) || calendar === "hebrew" && hebrewLeap(year) ? 13 : 12;
2130
+ ].includes(calendar) || calendar === "hebrew" && HebrewLeapYear(year) ? 13 : 12;
2159
2131
  }
2160
- function daysInMonth(calendar, year, month) {
2161
- const count = monthsInYear(calendar, year);
2162
- if (integer(month) < 1 || month > count) throw new RangeError("Invalid calendar month");
2163
- if (isLunisolar(calendar)) return tableMonthLength(calendar, year, month);
2164
- if (calendar === "islamic-umalqura") return tableMonthLength(calendar, year, month) ?? daysInMonth("islamic-civil", year, month);
2165
- if (isoLike(calendar)) return month === 12 ? 31 : monthStarts$1[month] - monthStarts$1[month - 1] + Number(month === 2 && DaysInYear(isoYear(calendar, year)) === 366);
2166
- const length = start(calendar, year + 1) - start(calendar, year);
2132
+ function ArithmeticCalendarDaysInMonth(calendar, year, month) {
2133
+ const count = ArithmeticCalendarMonthsInYear(calendar, year);
2134
+ if (integer$1(month) < 1 || month > count) throw new RangeError("Invalid calendar month");
2135
+ if (IsISOCalendar(calendar)) return month === 12 ? 31 : monthStarts$1[month] - monthStarts$1[month - 1] + Number(month === 2 && DaysInYear(CalendarISOYear(calendar, year)) === 366);
2136
+ const length = ArithmeticCalendarStartOfYear(calendar, year + 1) - ArithmeticCalendarStartOfYear(calendar, year);
2167
2137
  if ([
2168
2138
  "coptic",
2169
2139
  "ethiopic",
@@ -2172,7 +2142,7 @@ function daysInMonth(calendar, year, month) {
2172
2142
  if (calendar === "indian") return month === 1 ? 30 + Number(DaysInYear(year + 78) === 366) : month <= 6 ? 31 : 30;
2173
2143
  if (calendar === "islamic-civil" || calendar === "islamic-tbla") return month % 2 === 1 || month === 12 && length === 355 ? 30 : 29;
2174
2144
  if (calendar === "persian") return month <= 6 ? 31 : month < 12 ? 30 : length - 336;
2175
- const code = month + Number(!hebrewLeap(year) && month >= 6);
2145
+ const code = month + Number(!HebrewLeapYear(year) && month >= 6);
2176
2146
  if ([
2177
2147
  4,
2178
2148
  7,
@@ -2184,71 +2154,20 @@ function daysInMonth(calendar, year, month) {
2184
2154
  if (code === 3) return length % 10 === 3 ? 29 : 30;
2185
2155
  return 30;
2186
2156
  }
2187
- function monthCode(calendar, year, month) {
2188
- if (isLunisolar(calendar)) {
2189
- const leap = tableLeapMonth(calendar, year);
2190
- return "M" + String(month - Number(leap > 0 && month > leap)).padStart(2, "0") + (leap > 0 && month === leap + 1 ? "L" : "");
2191
- }
2192
- const leap = calendar === "hebrew" && hebrewLeap(year);
2157
+ function ArithmeticCalendarMonthCode(calendar, year, month) {
2158
+ const leap = calendar === "hebrew" && HebrewLeapYear(year);
2193
2159
  if (leap && month === 6) return "M05L";
2194
- return "M" + String(month - Number(leap && month > 6)).padStart(2, "0");
2195
- }
2196
- function monthFromCode(calendar, year, code, overflow) {
2197
- if (isLunisolar(calendar)) {
2198
- if (!/^M(0[1-9]|1[0-2])L?$/.test(code)) throw new RangeError("Invalid month code");
2199
- const number = Number(code.slice(1, 3)), leap = tableLeapMonth(calendar, year);
2200
- if (code.endsWith("L") && leap !== number && overflow === "reject") throw new RangeError("Leap month absent");
2201
- return number + Number(leap > 0 && (number > leap || number === leap && code.endsWith("L")));
2202
- }
2203
- if (calendar === "hebrew" && code === "M05L") {
2204
- if (!hebrewLeap(year) && overflow === "reject") throw new RangeError("Leap month absent");
2205
- return 6;
2206
- }
2207
- if (!/^M(0[1-9]|1[0-3])$/.test(code) || code === "M13" && ![
2208
- "coptic",
2209
- "ethiopic",
2210
- "ethioaa"
2211
- ].includes(calendar)) throw new RangeError("Invalid month code");
2212
- const month = Number(code.slice(1));
2213
- return month + Number(calendar === "hebrew" && hebrewLeap(year) && month >= 6);
2160
+ const code = month - Number(leap && month > 6);
2161
+ return "M" + (code < 10 ? "0" : "") + code;
2214
2162
  }
2215
- function calendarToEpochDayRaw(calendar, fields, overflow = "constrain") {
2216
- calendarCheck(calendar);
2217
- overflowCheck(overflow);
2218
- const year = yearCheck(fields.year);
2219
- let month;
2220
- if (fields.monthCode !== void 0) {
2221
- month = monthFromCode(calendar, year, fields.monthCode, overflow);
2222
- if (fields.month !== void 0 && integer(fields.month) !== month) throw new RangeError("Month and monthCode disagree");
2223
- } else {
2224
- if (fields.month === void 0) throw new TypeError("Month or monthCode required");
2225
- month = regulate(fields.month, 1, monthsInYear(calendar, year), overflow);
2226
- }
2227
- const day = regulate(fields.day, 1, daysInMonth(calendar, year, month), overflow);
2228
- let epoch = start(calendar, year) + day - 1;
2229
- for (let m = 1; m < month; m++) epoch += daysInMonth(calendar, year, m);
2230
- return integer(epoch);
2231
- }
2232
- function calendarFromEpochDay(calendar, epoch) {
2233
- return calendarFromEpochDayRaw(calendar, dayCheck(epoch));
2234
- }
2235
- function calendarFromEpochDayRaw(calendar, epoch) {
2236
- calendarCheck(calendar);
2237
- if (Math.abs(integer(epoch)) > 11e7) throw new RangeError("Calendar date out of range");
2238
- if (isLunisolar(calendar)) {
2239
- const value = tableDate(calendar, epoch);
2240
- return {
2241
- ...value,
2242
- monthCode: monthCode(calendar, value.year, value.month)
2243
- };
2244
- }
2163
+ function ArithmeticCalendarFromEpochDay(calendar, epoch) {
2245
2164
  const t = epoch * 864e5, civilYear = YearFromTime(t);
2246
- if (isoLike(calendar)) {
2165
+ if (IsISOCalendar(calendar)) {
2247
2166
  const year = civilYear - (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0), month = MonthFromTime(t) + 1;
2248
2167
  return {
2249
2168
  year,
2250
2169
  month,
2251
- monthCode: monthCode(calendar, year, month),
2170
+ monthCode: ArithmeticCalendarMonthCode(calendar, year, month),
2252
2171
  day: DateFromTime(t)
2253
2172
  };
2254
2173
  }
@@ -2262,7 +2181,6 @@ function calendarFromEpochDayRaw(calendar, epoch) {
2262
2181
  case "ethioaa":
2263
2182
  year = Math.floor((4 * (jd - 1723856) + 3) / 1461) + (calendar === "ethioaa" ? 5500 : 0);
2264
2183
  break;
2265
- case "islamic-umalqura":
2266
2184
  case "islamic-civil":
2267
2185
  case "islamic-tbla":
2268
2186
  year = Math.floor((30 * (jd - 1948440 + Number(calendar === "islamic-tbla")) + 10646) / 10631);
@@ -2275,18 +2193,18 @@ function calendarFromEpochDayRaw(calendar, epoch) {
2275
2193
  break;
2276
2194
  default: year = Math.floor((epoch + 2092590) * 492480 / 179876755) + 1;
2277
2195
  }
2278
- while (start(calendar, year) > epoch) year--;
2279
- while (start(calendar, year + 1) <= epoch) year++;
2280
- let month = 1, remaining = epoch - start(calendar, year);
2281
- while (remaining >= daysInMonth(calendar, year, month)) remaining -= daysInMonth(calendar, year, month++);
2196
+ while (ArithmeticCalendarStartOfYear(calendar, year) > epoch) year--;
2197
+ while (ArithmeticCalendarStartOfYear(calendar, year + 1) <= epoch) year++;
2198
+ let month = 1, remaining = epoch - ArithmeticCalendarStartOfYear(calendar, year);
2199
+ while (remaining >= ArithmeticCalendarDaysInMonth(calendar, year, month)) remaining -= ArithmeticCalendarDaysInMonth(calendar, year, month++);
2282
2200
  return {
2283
2201
  year,
2284
2202
  month,
2285
- monthCode: monthCode(calendar, year, month),
2203
+ monthCode: ArithmeticCalendarMonthCode(calendar, year, month),
2286
2204
  day: remaining + 1
2287
2205
  };
2288
2206
  }
2289
- const japaneseEras = [
2207
+ const JapaneseEras = [
2290
2208
  [
2291
2209
  18017,
2292
2210
  "reiwa",
@@ -2313,12 +2231,9 @@ const japaneseEras = [
2313
2231
  1867
2314
2232
  ]
2315
2233
  ];
2316
- function calendarEra(calendar, epoch, extended = false) {
2317
- const { year } = (extended ? calendarFromEpochDayRaw : calendarFromEpochDay)(calendar, epoch);
2234
+ function ArithmeticCalendarEra(calendar, epoch, year) {
2318
2235
  switch (calendar) {
2319
- case "iso8601":
2320
- case "chinese":
2321
- case "dangi": return;
2236
+ case "iso8601": return;
2322
2237
  case "buddhist": return {
2323
2238
  era: "be",
2324
2239
  eraYear: year
@@ -2348,13 +2263,12 @@ function calendarEra(calendar, epoch, extended = false) {
2348
2263
  era: year > 0 ? "roc" : "broc",
2349
2264
  eraYear: year > 0 ? year : 1 - year
2350
2265
  };
2351
- case "islamic-umalqura":
2352
2266
  case "islamic-civil":
2353
2267
  case "islamic-tbla": return {
2354
2268
  era: year > 0 ? "ah" : "bh",
2355
2269
  eraYear: year > 0 ? year : 1 - year
2356
2270
  };
2357
- case "japanese": for (const [start, era, offset] of japaneseEras) if (epoch >= start) return {
2271
+ case "japanese": for (const [start, era, offset] of JapaneseEras) if (epoch >= start) return {
2358
2272
  era,
2359
2273
  eraYear: year - offset
2360
2274
  };
@@ -2364,11 +2278,134 @@ function calendarEra(calendar, epoch, extended = false) {
2364
2278
  eraYear: year > 0 ? year : 1 - year
2365
2279
  };
2366
2280
  }
2281
+ // packages/temporal/calendar.ts
2282
+ const calendarIds = [
2283
+ ...arithmeticCalendars,
2284
+ "chinese",
2285
+ "dangi",
2286
+ "islamic-umalqura"
2287
+ ];
2288
+ function integer(value) {
2289
+ if (!Number.isSafeInteger(value)) throw new RangeError("Expected safe integer");
2290
+ return value;
2291
+ }
2292
+ function yearCheck(year) {
2293
+ if (Math.abs(integer(year)) > 4e5) throw new RangeError("Calendar year out of range");
2294
+ return year;
2295
+ }
2296
+ function dayCheck(day) {
2297
+ if (integer(day) < -100000001 || day > 1e8) throw new RangeError("Calendar date out of range");
2298
+ return day;
2299
+ }
2300
+ function calendarCheck(calendar) {
2301
+ if (!calendarIds.includes(calendar)) throw new RangeError("Unsupported calendar");
2302
+ }
2303
+ function overflowCheck(overflow) {
2304
+ if (overflow !== "constrain" && overflow !== "reject") throw new RangeError("Invalid overflow");
2305
+ }
2306
+ function regulate(value, min, max, overflow) {
2307
+ if (!Number.isInteger(value)) throw new RangeError("Expected finite integer");
2308
+ if (overflow === "reject" && (value < min || value > max)) throw new RangeError("Calendar field out of range");
2309
+ return Math.min(Math.max(value, min), max);
2310
+ }
2311
+ function start(calendar, year) {
2312
+ if (isLunisolar(calendar)) return tableYearStart(calendar, year);
2313
+ if (calendar === "islamic-umalqura") return tableYearStart(calendar, year) ?? ArithmeticCalendarStartOfYear("islamic-civil", year);
2314
+ return ArithmeticCalendarStartOfYear(calendar, year);
2315
+ }
2316
+ function monthsInYear(calendar, year) {
2317
+ calendarCheck(calendar);
2318
+ yearCheck(year);
2319
+ if (isLunisolar(calendar)) return tableLeapMonth(calendar, year) ? 13 : 12;
2320
+ return calendar === "islamic-umalqura" ? 12 : ArithmeticCalendarMonthsInYear(calendar, year);
2321
+ }
2322
+ function daysInMonth(calendar, year, month) {
2323
+ const count = monthsInYear(calendar, year);
2324
+ if (integer(month) < 1 || month > count) throw new RangeError("Invalid calendar month");
2325
+ if (isLunisolar(calendar)) return tableMonthLength(calendar, year, month);
2326
+ if (calendar === "islamic-umalqura") return tableMonthLength(calendar, year, month) ?? daysInMonth("islamic-civil", year, month);
2327
+ return ArithmeticCalendarDaysInMonth(calendar, year, month);
2328
+ }
2329
+ function monthCode(calendar, year, month) {
2330
+ if (isLunisolar(calendar)) {
2331
+ const leap = tableLeapMonth(calendar, year);
2332
+ return "M" + String(month - Number(leap > 0 && month > leap)).padStart(2, "0") + (leap > 0 && month === leap + 1 ? "L" : "");
2333
+ }
2334
+ return ArithmeticCalendarMonthCode(calendar === "islamic-umalqura" ? "islamic-civil" : calendar, year, month);
2335
+ }
2336
+ function monthFromCode(calendar, year, code, overflow) {
2337
+ if (isLunisolar(calendar)) {
2338
+ if (!/^M(0[1-9]|1[0-2])L?$/.test(code)) throw new RangeError("Invalid month code");
2339
+ const number = Number(code.slice(1, 3)), leap = tableLeapMonth(calendar, year);
2340
+ if (code.endsWith("L") && leap !== number && overflow === "reject") throw new RangeError("Leap month absent");
2341
+ return number + Number(leap > 0 && (number > leap || number === leap && code.endsWith("L")));
2342
+ }
2343
+ if (calendar === "hebrew" && code === "M05L") {
2344
+ if (!HebrewLeapYear(year) && overflow === "reject") throw new RangeError("Leap month absent");
2345
+ return 6;
2346
+ }
2347
+ if (!/^M(0[1-9]|1[0-3])$/.test(code) || code === "M13" && ![
2348
+ "coptic",
2349
+ "ethiopic",
2350
+ "ethioaa"
2351
+ ].includes(calendar)) throw new RangeError("Invalid month code");
2352
+ const month = Number(code.slice(1));
2353
+ return month + Number(calendar === "hebrew" && HebrewLeapYear(year) && month >= 6);
2354
+ }
2355
+ function calendarToEpochDayRaw(calendar, fields, overflow = "constrain") {
2356
+ calendarCheck(calendar);
2357
+ overflowCheck(overflow);
2358
+ const year = yearCheck(fields.year);
2359
+ let month;
2360
+ if (fields.monthCode !== void 0) {
2361
+ month = monthFromCode(calendar, year, fields.monthCode, overflow);
2362
+ if (fields.month !== void 0 && integer(fields.month) !== month) throw new RangeError("Month and monthCode disagree");
2363
+ } else {
2364
+ if (fields.month === void 0) throw new TypeError("Month or monthCode required");
2365
+ month = regulate(fields.month, 1, monthsInYear(calendar, year), overflow);
2366
+ }
2367
+ const day = regulate(fields.day, 1, daysInMonth(calendar, year, month), overflow);
2368
+ let epoch = start(calendar, year) + day - 1;
2369
+ for (let m = 1; m < month; m++) epoch += daysInMonth(calendar, year, m);
2370
+ return integer(epoch);
2371
+ }
2372
+ function calendarFromEpochDay(calendar, epoch) {
2373
+ return calendarFromEpochDayRaw(calendar, dayCheck(epoch));
2374
+ }
2375
+ function calendarFromEpochDayRaw(calendar, epoch) {
2376
+ calendarCheck(calendar);
2377
+ if (Math.abs(integer(epoch)) > 11e7) throw new RangeError("Calendar date out of range");
2378
+ if (isLunisolar(calendar)) {
2379
+ const value = tableDate(calendar, epoch);
2380
+ return {
2381
+ ...value,
2382
+ monthCode: monthCode(calendar, value.year, value.month)
2383
+ };
2384
+ }
2385
+ if (calendar !== "islamic-umalqura") return ArithmeticCalendarFromEpochDay(calendar, epoch);
2386
+ const jd = epoch + 2440588;
2387
+ let year = Math.floor((30 * (jd - 1948440) + 10646) / 10631);
2388
+ while (start(calendar, year) > epoch) year--;
2389
+ while (start(calendar, year + 1) <= epoch) year++;
2390
+ let month = 1, remaining = epoch - start(calendar, year);
2391
+ while (remaining >= daysInMonth(calendar, year, month)) remaining -= daysInMonth(calendar, year, month++);
2392
+ return {
2393
+ year,
2394
+ month,
2395
+ monthCode: monthCode(calendar, year, month),
2396
+ day: remaining + 1
2397
+ };
2398
+ }
2399
+ function calendarEra(calendar, epoch, extended = false) {
2400
+ const { year } = (extended ? calendarFromEpochDayRaw : calendarFromEpochDay)(calendar, epoch);
2401
+ if (calendar === "chinese" || calendar === "dangi") return void 0;
2402
+ return ArithmeticCalendarEra(calendar === "islamic-umalqura" ? "islamic-civil" : calendar, epoch, year);
2403
+ }
2367
2404
  function calendarYearFromEra(calendar, era, eraYear) {
2368
2405
  calendarCheck(calendar);
2369
2406
  integer(eraYear);
2370
2407
  if (calendar === "japanese") {
2371
- for (const [, name, offset] of japaneseEras) if (era === name) return yearCheck(eraYear + offset);
2408
+ for (const [, name, offset] of JapaneseEras) if (era === name) return yearCheck(eraYear + offset);
2372
2409
  }
2373
2410
  if (calendar === "ethiopic" && era === "aa") return yearCheck(eraYear - 5500);
2374
2411
  const names = {
@@ -2391,7 +2428,7 @@ function calendarYearFromEra(calendar, era, eraYear) {
2391
2428
  if (index < 0) throw new RangeError("Invalid era");
2392
2429
  return yearCheck(index === 1 ? 1 - eraYear : eraYear);
2393
2430
  }
2394
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/legacy-lunisolar-date.ts
2431
+ // packages/temporal/legacy-lunisolar-date.ts
2395
2432
  const Constructor$1 = globalThis.Intl?.DateTimeFormat;
2396
2433
  const nativeParts$1 = Constructor$1?.prototype.formatToParts;
2397
2434
  const NumberConstructor$3 = globalThis.Intl?.NumberFormat;
@@ -2582,7 +2619,7 @@ function joinCalendarRangeParts(formatter, start, end, parts) {
2582
2619
  }))
2583
2620
  ];
2584
2621
  }
2585
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/legacy-calendar-date.ts
2622
+ // packages/temporal/legacy-calendar-date.ts
2586
2623
  const Constructor = globalThis.Intl?.DateTimeFormat;
2587
2624
  const NumberConstructor$2 = globalThis.Intl?.NumberFormat;
2588
2625
  const numberFormat$2 = NumberConstructor$2 && Object.getOwnPropertyDescriptor(NumberConstructor$2.prototype, "format")?.get;
@@ -2815,7 +2852,7 @@ function legacyCalendarRangeParts(first, last, parts, rangeParts, resolved) {
2815
2852
  }
2816
2853
  return joinCalendarRangeParts(first.formatter, start, end, rangeParts);
2817
2854
  }
2818
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/legacy-extended-date.ts
2855
+ // packages/temporal/legacy-extended-date.ts
2819
2856
  const legacyTimeZoneName = Symbol();
2820
2857
  const limit = 864e13;
2821
2858
  const cycle = 146097 * 864e5;
@@ -2896,7 +2933,7 @@ function legacyDateTimeRangeFormat(first, last, format, parts, resolved) {
2896
2933
  if (!clipped(first) && !clipped(last) || !gregorian(first.formatter, resolved)) return format.call(first.formatter, first.milliseconds, last.milliseconds);
2897
2934
  return legacyDateTimeRangeParts(first, last, parts, resolved).map((part) => part.value).join("");
2898
2935
  }
2899
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/legacy-zoned-date.ts
2936
+ // packages/temporal/legacy-zoned-date.ts
2900
2937
  const zones = /* @__PURE__ */ new WeakMap();
2901
2938
  const NumberConstructor = globalThis.Intl?.NumberFormat;
2902
2939
  const numberFormat = NumberConstructor && Object.getOwnPropertyDescriptor(NumberConstructor.prototype, "format")?.get;
@@ -2956,7 +2993,7 @@ function offsetName(Constructor, resolved, offset, long, parts) {
2956
2993
  const replacement = number(hour) + (long || minute || second ? separator + two(minute) : "") + (second ? separator + two(second) : "");
2957
2994
  return pattern.replace(/0?1(?:\D+00)?/, replacement);
2958
2995
  }
2959
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/locale.ts
2996
+ // packages/temporal/locale.ts
2960
2997
  const dateUTC = Date.UTC;
2961
2998
  let dateTimeConstructor = globalThis.Intl?.DateTimeFormat;
2962
2999
  dateTimeConstructor?.__formatTemporal;
@@ -3139,14 +3176,14 @@ function legacyDateTimeOption(key, value) {
3139
3176
  if (key === "fractionalSecondDigits") return +value;
3140
3177
  return ToString(value);
3141
3178
  }
3142
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/date-bridge.ts
3179
+ // packages/temporal/date-bridge.ts
3143
3180
  const getTime = Function.prototype.call.bind(Date.prototype.getTime);
3144
3181
  function createDateToTemporalInstant(create) {
3145
3182
  return { toTemporalInstant() {
3146
3183
  return create(BigInt(getTime(this)) * 1000000n);
3147
3184
  } }.toTemporalInstant;
3148
3185
  }
3149
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/detect.ts
3186
+ // packages/temporal/detect.ts
3150
3187
  const constructors = [
3151
3188
  "Instant",
3152
3189
  "Duration",
@@ -3174,7 +3211,7 @@ function needsTemporal() {
3174
3211
  for (let i = 0; i < nowMethods.length; i++) if (typeof now[nowMethods[i]] !== "function") return true;
3175
3212
  return false;
3176
3213
  }
3177
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js
3214
+ // node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js
3178
3215
  const DIV_PRECISION = 40;
3179
3216
  function removeTrailingZeros(mantissa, exponent) {
3180
3217
  if (mantissa === 0n) return [0n, 0];
@@ -3654,7 +3691,7 @@ var BigDecimal = class BigDecimal {
3654
3691
  return BigDecimal._create(0n, 0, 1, false);
3655
3692
  }
3656
3693
  };
3657
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma262-abstract/ToNumber.js
3694
+ // packages/ecma262-abstract/ToNumber.js
3658
3695
  /**
3659
3696
  * ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
3660
3697
  * https://tc39.es/ecma262/#sec-tonumber
@@ -3663,7 +3700,7 @@ var BigDecimal = class BigDecimal {
3663
3700
  function ToNumber(arg) {
3664
3701
  return new BigDecimal(+arg);
3665
3702
  }
3666
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DateTimeFormat/TemporalDateTime.js
3703
+ // packages/ecma402-abstract/DateTimeFormat/TemporalDateTime.js
3667
3704
  const readers$1 = [];
3668
3705
  const registered = /* @__PURE__ */ new WeakSet();
3669
3706
  function registerTemporalDateTimeNamespace(temporal) {
@@ -3746,11 +3783,11 @@ function ToDateTimeFormattable(value) {
3746
3783
  return ToNumber(value);
3747
3784
  }
3748
3785
  new BigDecimal(0);
3749
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DateTimeFormat/HandleDateTimeValue.js
3786
+ // packages/ecma402-abstract/DateTimeFormat/HandleDateTimeValue.js
3750
3787
  function isTemporalDateTimeValue(value) {
3751
3788
  return Object.prototype.hasOwnProperty.call(value, "kind");
3752
3789
  }
3753
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/legacy-intl.ts
3790
+ // packages/temporal/legacy-intl.ts
3754
3791
  const now = Date.now;
3755
3792
  function installLegacyDateTimeFormat(namespace) {
3756
3793
  const Native = globalThis.Intl?.DateTimeFormat;
@@ -3913,7 +3950,7 @@ function installLegacyDateTimeFormat(namespace) {
3913
3950
  });
3914
3951
  globalThis.Intl.DateTimeFormat = DateTimeFormat;
3915
3952
  }
3916
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DurationFormat/constants.js
3953
+ // packages/ecma402-abstract/DurationFormat/constants.js
3917
3954
  const TABLE_1 = [
3918
3955
  "years",
3919
3956
  "months",
@@ -3926,7 +3963,7 @@ const TABLE_1 = [
3926
3963
  "microseconds",
3927
3964
  "nanoseconds"
3928
3965
  ];
3929
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DurationFormat/DurationRecordSign.js
3966
+ // packages/ecma402-abstract/DurationFormat/DurationRecordSign.js
3930
3967
  function DurationRecordSign(record) {
3931
3968
  for (const key of TABLE_1) {
3932
3969
  if (record[key] < 0) return -1;
@@ -3934,7 +3971,7 @@ function DurationRecordSign(record) {
3934
3971
  }
3935
3972
  return 0;
3936
3973
  }
3937
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DurationFormat/IsValidDurationRecord.js
3974
+ // packages/ecma402-abstract/DurationFormat/IsValidDurationRecord.js
3938
3975
  function IsValidDurationRecord(record) {
3939
3976
  const sign = DurationRecordSign(record);
3940
3977
  for (const key of TABLE_1) {
@@ -3953,7 +3990,7 @@ function IsValidDurationRecord(record) {
3953
3990
  const limit = BigInt(2 ** 53) * billion;
3954
3991
  return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
3955
3992
  }
3956
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
3993
+ // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
3957
3994
  function memoize(fn, options) {
3958
3995
  const cache = options && options.cache ? options.cache : cacheDefault;
3959
3996
  const serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -4018,20 +4055,20 @@ const strategies = {
4018
4055
  variadic: strategyVariadic,
4019
4056
  monadic: strategyMonadic
4020
4057
  };
4021
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/utils.js
4058
+ // packages/ecma402-abstract/utils.js
4022
4059
  function invariant(condition, message, Err = Error) {
4023
4060
  if (!condition) throw new Err(message);
4024
4061
  }
4025
4062
  memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
4026
4063
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
4027
4064
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
4028
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
4065
+ // packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
4029
4066
  function ToIntegerIfIntegral(arg) {
4030
4067
  const number = ToNumber(arg);
4031
4068
  invariant(number.isInteger(), "Duration field is not an integer", RangeError);
4032
4069
  return number.isZero() ? 0 : number.toNumber();
4033
4070
  }
4034
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
4071
+ // packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
4035
4072
  function ToDurationRecord(input) {
4036
4073
  if ((typeof input !== "object" || input === null) && typeof input !== "function") {
4037
4074
  if (typeof input === "string") throw new RangeError("Invalid duration format");
@@ -4072,7 +4109,7 @@ function ToDurationRecord(input) {
4072
4109
  if (!IsValidDurationRecord(result)) throw new RangeError("Invalid duration format");
4073
4110
  return result;
4074
4111
  }
4075
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/ecma402-abstract/DurationFormat/ToTemporalDurationRecord.js
4112
+ // packages/ecma402-abstract/DurationFormat/ToTemporalDurationRecord.js
4076
4113
  const fields = [
4077
4114
  "years",
4078
4115
  "months",
@@ -4121,7 +4158,7 @@ function ToTemporalDurationRecord(input) {
4121
4158
  }
4122
4159
  return ToDurationRecord(input);
4123
4160
  }
4124
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/legacy-durationformat.ts
4161
+ // packages/temporal/legacy-durationformat.ts
4125
4162
  function installLegacyDurationFormat(namespace) {
4126
4163
  const Native = globalThis.Intl?.DurationFormat;
4127
4164
  if (!Native || Native.__addTemporalNamespace) return;
@@ -4144,7 +4181,7 @@ function installLegacyDurationFormat(namespace) {
4144
4181
  configurable: true
4145
4182
  });
4146
4183
  }
4147
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/install.ts
4184
+ // packages/temporal/install.ts
4148
4185
  function installTemporal(force = false) {
4149
4186
  const target = globalThis, date = Date.prototype, replace = force || needsTemporal();
4150
4187
  if (replace) Object.defineProperty(target, "Temporal", {
@@ -4170,7 +4207,7 @@ function installTemporal(force = false) {
4170
4207
  });
4171
4208
  }
4172
4209
  }
4173
- // ../../../../../../../../execroot/_main/bazel-out/local_linux_gnu-opt/bin/packages/temporal/polyfill-force.ts
4210
+ // packages/temporal/polyfill-force.ts
4174
4211
  installTemporal(true);
4175
4212
 
4176
4213
  //# sourceMappingURL=polyfill-force.js.map