@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/index.js +275 -237
- package/index.js.map +1 -1
- package/native.js +1 -1
- package/package.json +6 -3
- package/polyfill-force.js +204 -167
- package/polyfill-force.js.map +1 -1
- package/polyfill.js +204 -167
- package/polyfill.js.map +1 -1
- package/should-polyfill.js +2 -2
- package/standalone.js +275 -237
- package/standalone.js.map +1 -1
- package/wasm-native.js +287 -249
- package/wasm-native.js.map +1 -1
- package/wasm.js +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nativeTemporal } from "./native.js";
|
|
2
|
-
//
|
|
2
|
+
// packages/ecma262-abstract/ToString.js
|
|
3
3
|
/**
|
|
4
4
|
* https://tc39.es/ecma262/#sec-tostring
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ function ToString(o) {
|
|
|
7
7
|
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
|
|
8
8
|
return String(o);
|
|
9
9
|
}
|
|
10
|
-
//
|
|
10
|
+
// node_modules/.aspect_rules_js/@formatjs_generated+tz@0.0.0/node_modules/@formatjs_generated/tz/temporal-names.js
|
|
11
11
|
var temporal_names_default = [
|
|
12
12
|
"Africa/Abidjan",
|
|
13
13
|
"Africa/Accra",
|
|
@@ -677,7 +677,7 @@ const steps = {
|
|
|
677
677
|
"Pacific/Saipan": 3022200,
|
|
678
678
|
"Pacific/Tongatapu": 3024e3
|
|
679
679
|
};
|
|
680
|
-
//
|
|
680
|
+
// node_modules/.aspect_rules_js/@formatjs_generated+tz@0.0.0/node_modules/@formatjs_generated/tz/links.js
|
|
681
681
|
var links_default = {
|
|
682
682
|
"Africa/Accra": "Africa/Abidjan",
|
|
683
683
|
"Africa/Addis_Ababa": "Africa/Nairobi",
|
|
@@ -933,7 +933,7 @@ var links_default = {
|
|
|
933
933
|
"WET": "Europe/Lisbon",
|
|
934
934
|
"Zulu": "Etc/UTC"
|
|
935
935
|
};
|
|
936
|
-
//
|
|
936
|
+
// node_modules/.aspect_rules_js/@formatjs_generated+tz@0.0.0/node_modules/@formatjs_generated/tz/primary.js
|
|
937
937
|
var primary_default = {
|
|
938
938
|
"Africa/Asmera": "Africa/Asmara",
|
|
939
939
|
"Africa/Timbuktu": "Africa/Bamako",
|
|
@@ -1084,7 +1084,7 @@ var primary_default = {
|
|
|
1084
1084
|
"WET": "Europe/Lisbon",
|
|
1085
1085
|
"Zulu": "UTC"
|
|
1086
1086
|
};
|
|
1087
|
-
//
|
|
1087
|
+
// packages/ecma262-abstract/DateOperations.js
|
|
1088
1088
|
const MS_PER_DAY = 864e5;
|
|
1089
1089
|
function Day(t) {
|
|
1090
1090
|
return Math.floor(t / MS_PER_DAY);
|
|
@@ -1147,7 +1147,7 @@ function DateFromTime(t) {
|
|
|
1147
1147
|
if (mft === 11) return dwy - 333 - leap;
|
|
1148
1148
|
throw new Error("Invalid time");
|
|
1149
1149
|
}
|
|
1150
|
-
//
|
|
1150
|
+
// packages/temporal/kernel.ts
|
|
1151
1151
|
const second$1 = 1000000000n;
|
|
1152
1152
|
const day$3 = 86400n * second$1;
|
|
1153
1153
|
const limit$6 = 100000000n * day$3;
|
|
@@ -1225,7 +1225,7 @@ function epochNanosecondsToISO(value) {
|
|
|
1225
1225
|
nanosecond: Number(time % 1000n)
|
|
1226
1226
|
};
|
|
1227
1227
|
}
|
|
1228
|
-
//
|
|
1228
|
+
// packages/temporal/host-timezone.ts
|
|
1229
1229
|
const Constructor$3 = globalThis.Intl?.DateTimeFormat;
|
|
1230
1230
|
const parts$1 = Constructor$3?.prototype.formatToParts;
|
|
1231
1231
|
const nowMilliseconds = Date.now;
|
|
@@ -1387,7 +1387,7 @@ function createHostTimeZone(timeZone) {
|
|
|
1387
1387
|
transition
|
|
1388
1388
|
};
|
|
1389
1389
|
}
|
|
1390
|
-
//
|
|
1390
|
+
// node_modules/.aspect_rules_js/@formatjs_generated+datetimeformat.calendars@0.0.0/node_modules/@formatjs_generated/datetimeformat.calendars/fallback-eras.js
|
|
1391
1391
|
const beforeHijrah = {
|
|
1392
1392
|
"ady": [
|
|
1393
1393
|
"BH",
|
|
@@ -2700,7 +2700,7 @@ const beforeHijrah = {
|
|
|
2700
2700
|
"BH"
|
|
2701
2701
|
]
|
|
2702
2702
|
};
|
|
2703
|
-
//
|
|
2703
|
+
// packages/temporal/fallback-data.ts
|
|
2704
2704
|
function fallbackTimeZoneIdentifiers() {
|
|
2705
2705
|
return {
|
|
2706
2706
|
primary: primary_default,
|
|
@@ -2711,7 +2711,7 @@ function fallbackTimeZoneIdentifiers() {
|
|
|
2711
2711
|
function fallbackTimeZonePrimary() {
|
|
2712
2712
|
return primary_default;
|
|
2713
2713
|
}
|
|
2714
|
-
//
|
|
2714
|
+
// packages/temporal/lunisolar.ts
|
|
2715
2715
|
const day$1 = 86400000n;
|
|
2716
2716
|
const month = day$1 * 295305888531n / 10000000000n;
|
|
2717
2717
|
const year = day$1 * 146097n / 400n;
|
|
@@ -2768,7 +2768,7 @@ function approximateLunisolarYear(calendar, relatedYear) {
|
|
|
2768
2768
|
leap
|
|
2769
2769
|
};
|
|
2770
2770
|
}
|
|
2771
|
-
//
|
|
2771
|
+
// node_modules/.aspect_rules_js/@formatjs_generated+icu.calendar@0.0.0/node_modules/@formatjs_generated/icu.calendar/host-chinese.js
|
|
2772
2772
|
const ranges$2 = [{
|
|
2773
2773
|
firstYear: 1900,
|
|
2774
2774
|
startDay: -25537,
|
|
@@ -2978,7 +2978,7 @@ const ranges$2 = [{
|
|
|
2978
2978
|
1453
|
|
2979
2979
|
]
|
|
2980
2980
|
}];
|
|
2981
|
-
//
|
|
2981
|
+
// node_modules/.aspect_rules_js/@formatjs_generated+icu.calendar@0.0.0/node_modules/@formatjs_generated/icu.calendar/host-dangi.js
|
|
2982
2982
|
const ranges$1 = [{
|
|
2983
2983
|
firstYear: 1900,
|
|
2984
2984
|
startDay: -25537,
|
|
@@ -3188,7 +3188,7 @@ const ranges$1 = [{
|
|
|
3188
3188
|
1453
|
|
3189
3189
|
]
|
|
3190
3190
|
}];
|
|
3191
|
-
//
|
|
3191
|
+
// packages/temporal/host-calendar-data.ts
|
|
3192
3192
|
const cache$1 = /* @__PURE__ */ new Map();
|
|
3193
3193
|
function ranges(calendar) {
|
|
3194
3194
|
let result = cache$1.get(calendar);
|
|
@@ -3225,7 +3225,7 @@ function compactCalendarYear(calendar, year) {
|
|
|
3225
3225
|
};
|
|
3226
3226
|
}
|
|
3227
3227
|
}
|
|
3228
|
-
//
|
|
3228
|
+
// packages/temporal/host-calendar.ts
|
|
3229
3229
|
const Constructor$2 = globalThis.Intl?.DateTimeFormat;
|
|
3230
3230
|
const parts = Constructor$2?.prototype.formatToParts;
|
|
3231
3231
|
const resolved = Constructor$2?.prototype.resolvedOptions;
|
|
@@ -3327,7 +3327,7 @@ function hostCalendarAddMonths(calendar, year, month, delta) {
|
|
|
3327
3327
|
function hostCalendarMonthDifference(calendar, oneYear, oneMonth, twoYear, twoMonth) {
|
|
3328
3328
|
return lunisolarMonthSerial(hostCalendarYear(calendar, twoYear).starts[twoMonth - 1]) - lunisolarMonthSerial(hostCalendarYear(calendar, oneYear).starts[oneMonth - 1]);
|
|
3329
3329
|
}
|
|
3330
|
-
//
|
|
3330
|
+
// packages/temporal/calendar-table.ts
|
|
3331
3331
|
function isLunisolar(calendar) {
|
|
3332
3332
|
return calendar === "chinese" || calendar === "dangi";
|
|
3333
3333
|
}
|
|
@@ -3357,25 +3357,21 @@ function tableAddMonths(calendar, year, month, months) {
|
|
|
3357
3357
|
function tableMonthDifference(calendar, oneYear, oneMonth, twoYear, twoMonth) {
|
|
3358
3358
|
return hostCalendarMonthDifference(calendar, oneYear, oneMonth, twoYear, twoMonth);
|
|
3359
3359
|
}
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
],
|
|
3376
|
-
"chinese",
|
|
3377
|
-
"dangi",
|
|
3378
|
-
"islamic-umalqura"
|
|
3360
|
+
// packages/ecma402-abstract/Calendar/Arithmetic.js
|
|
3361
|
+
const arithmeticCalendars = [
|
|
3362
|
+
"iso8601",
|
|
3363
|
+
"gregory",
|
|
3364
|
+
"buddhist",
|
|
3365
|
+
"japanese",
|
|
3366
|
+
"roc",
|
|
3367
|
+
"coptic",
|
|
3368
|
+
"ethiopic",
|
|
3369
|
+
"ethioaa",
|
|
3370
|
+
"hebrew",
|
|
3371
|
+
"indian",
|
|
3372
|
+
"islamic-civil",
|
|
3373
|
+
"islamic-tbla",
|
|
3374
|
+
"persian"
|
|
3379
3375
|
];
|
|
3380
3376
|
const monthStarts = [
|
|
3381
3377
|
0,
|
|
@@ -3391,42 +3387,23 @@ const monthStarts = [
|
|
|
3391
3387
|
304,
|
|
3392
3388
|
334
|
|
3393
3389
|
];
|
|
3394
|
-
const mod = (value, divisor) => value - Math.floor(value / divisor) * divisor;
|
|
3395
|
-
function integer$
|
|
3390
|
+
const mod$1 = (value, divisor) => value - Math.floor(value / divisor) * divisor;
|
|
3391
|
+
function integer$3(value) {
|
|
3396
3392
|
if (!Number.isSafeInteger(value)) throw new RangeError("Expected safe integer");
|
|
3397
3393
|
return value;
|
|
3398
3394
|
}
|
|
3399
|
-
function
|
|
3400
|
-
|
|
3401
|
-
return year;
|
|
3402
|
-
}
|
|
3403
|
-
function dayCheck(day) {
|
|
3404
|
-
if (integer$2(day) < -100000001 || day > 1e8) throw new RangeError("Calendar date out of range");
|
|
3405
|
-
return day;
|
|
3406
|
-
}
|
|
3407
|
-
function calendarCheck(calendar) {
|
|
3408
|
-
if (!calendarIds.includes(calendar)) throw new RangeError("Unsupported calendar");
|
|
3409
|
-
}
|
|
3410
|
-
function overflowCheck(overflow) {
|
|
3411
|
-
if (overflow !== "constrain" && overflow !== "reject") throw new RangeError("Invalid overflow");
|
|
3412
|
-
}
|
|
3413
|
-
function regulate$1(value, min, max, overflow) {
|
|
3414
|
-
if (!Number.isInteger(value)) throw new RangeError("Expected finite integer");
|
|
3415
|
-
if (overflow === "reject" && (value < min || value > max)) throw new RangeError("Calendar field out of range");
|
|
3416
|
-
return Math.min(Math.max(value, min), max);
|
|
3417
|
-
}
|
|
3418
|
-
function hebrewLeap(year) {
|
|
3419
|
-
return mod(7 * year + 1, 19) < 7;
|
|
3395
|
+
function HebrewLeapYear(year) {
|
|
3396
|
+
return mod$1(7 * year + 1, 19) < 7;
|
|
3420
3397
|
}
|
|
3421
|
-
function
|
|
3398
|
+
function HebrewElapsedMonths(year) {
|
|
3422
3399
|
return Math.floor((235 * year - 234) / 19);
|
|
3423
3400
|
}
|
|
3424
3401
|
function hebrewDelay(year) {
|
|
3425
|
-
const months =
|
|
3402
|
+
const months = HebrewElapsedMonths(year);
|
|
3426
3403
|
const day = 29 * months + Math.floor((12084 + 13753 * months) / 25920);
|
|
3427
|
-
return day + Number(mod(3 * (day + 1), 7) < 3);
|
|
3404
|
+
return day + Number(mod$1(3 * (day + 1), 7) < 3);
|
|
3428
3405
|
}
|
|
3429
|
-
function
|
|
3406
|
+
function IsISOCalendar(calendar) {
|
|
3430
3407
|
return [
|
|
3431
3408
|
"iso8601",
|
|
3432
3409
|
"gregory",
|
|
@@ -3435,13 +3412,11 @@ function isoLike(calendar) {
|
|
|
3435
3412
|
"roc"
|
|
3436
3413
|
].includes(calendar);
|
|
3437
3414
|
}
|
|
3438
|
-
function
|
|
3415
|
+
function CalendarISOYear(calendar, year) {
|
|
3439
3416
|
return year + (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0);
|
|
3440
3417
|
}
|
|
3441
|
-
function
|
|
3442
|
-
if (
|
|
3443
|
-
if (calendar === "islamic-umalqura") return tableYearStart(calendar, year) ?? start("islamic-civil", year);
|
|
3444
|
-
if (isoLike(calendar)) return DayFromYear(isoYear(calendar, year));
|
|
3418
|
+
function ArithmeticCalendarStartOfYear(calendar, year) {
|
|
3419
|
+
if (IsISOCalendar(calendar)) return DayFromYear(CalendarISOYear(calendar, year));
|
|
3445
3420
|
switch (calendar) {
|
|
3446
3421
|
case "coptic": return -615923 + 365 * year + Math.floor(year / 4);
|
|
3447
3422
|
case "ethiopic": return -716732 + 365 * year + Math.floor(year / 4);
|
|
@@ -3457,34 +3432,18 @@ function start(calendar, year) {
|
|
|
3457
3432
|
const present = hebrewDelay(year);
|
|
3458
3433
|
return -2092590 + present + (hebrewDelay(year + 1) - present === 356 ? 2 : present - hebrewDelay(year - 1) === 382 ? 1 : 0);
|
|
3459
3434
|
}
|
|
3460
|
-
function
|
|
3461
|
-
calendarCheck(calendar);
|
|
3462
|
-
yearCheck(year);
|
|
3463
|
-
const native = nativeTemporal();
|
|
3464
|
-
if (native) return native.calendarStartOfYear(calendar, year);
|
|
3465
|
-
return start(calendar, year);
|
|
3466
|
-
}
|
|
3467
|
-
function monthsInYear(calendar, year) {
|
|
3468
|
-
calendarCheck(calendar);
|
|
3469
|
-
yearCheck(year);
|
|
3470
|
-
const native = nativeTemporal();
|
|
3471
|
-
if (native) return native.calendarMonthsInYear(calendar, year);
|
|
3472
|
-
if (isLunisolar(calendar)) return tableLeapMonth(calendar, year) ? 13 : 12;
|
|
3435
|
+
function ArithmeticCalendarMonthsInYear(calendar, year) {
|
|
3473
3436
|
return [
|
|
3474
3437
|
"coptic",
|
|
3475
3438
|
"ethiopic",
|
|
3476
3439
|
"ethioaa"
|
|
3477
|
-
].includes(calendar) || calendar === "hebrew" &&
|
|
3440
|
+
].includes(calendar) || calendar === "hebrew" && HebrewLeapYear(year) ? 13 : 12;
|
|
3478
3441
|
}
|
|
3479
|
-
function
|
|
3480
|
-
const
|
|
3481
|
-
if (
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
if (isLunisolar(calendar)) return tableMonthLength(calendar, year, month);
|
|
3485
|
-
if (calendar === "islamic-umalqura") return tableMonthLength(calendar, year, month) ?? daysInMonth("islamic-civil", year, month);
|
|
3486
|
-
if (isoLike(calendar)) return month === 12 ? 31 : monthStarts[month] - monthStarts[month - 1] + Number(month === 2 && DaysInYear(isoYear(calendar, year)) === 366);
|
|
3487
|
-
const length = start(calendar, year + 1) - start(calendar, year);
|
|
3442
|
+
function ArithmeticCalendarDaysInMonth(calendar, year, month) {
|
|
3443
|
+
const count = ArithmeticCalendarMonthsInYear(calendar, year);
|
|
3444
|
+
if (integer$3(month) < 1 || month > count) throw new RangeError("Invalid calendar month");
|
|
3445
|
+
if (IsISOCalendar(calendar)) return month === 12 ? 31 : monthStarts[month] - monthStarts[month - 1] + Number(month === 2 && DaysInYear(CalendarISOYear(calendar, year)) === 366);
|
|
3446
|
+
const length = ArithmeticCalendarStartOfYear(calendar, year + 1) - ArithmeticCalendarStartOfYear(calendar, year);
|
|
3488
3447
|
if ([
|
|
3489
3448
|
"coptic",
|
|
3490
3449
|
"ethiopic",
|
|
@@ -3493,7 +3452,7 @@ function daysInMonth(calendar, year, month) {
|
|
|
3493
3452
|
if (calendar === "indian") return month === 1 ? 30 + Number(DaysInYear(year + 78) === 366) : month <= 6 ? 31 : 30;
|
|
3494
3453
|
if (calendar === "islamic-civil" || calendar === "islamic-tbla") return month % 2 === 1 || month === 12 && length === 355 ? 30 : 29;
|
|
3495
3454
|
if (calendar === "persian") return month <= 6 ? 31 : month < 12 ? 30 : length - 336;
|
|
3496
|
-
const code = month + Number(!
|
|
3455
|
+
const code = month + Number(!HebrewLeapYear(year) && month >= 6);
|
|
3497
3456
|
if ([
|
|
3498
3457
|
4,
|
|
3499
3458
|
7,
|
|
@@ -3505,14 +3464,196 @@ function daysInMonth(calendar, year, month) {
|
|
|
3505
3464
|
if (code === 3) return length % 10 === 3 ? 29 : 30;
|
|
3506
3465
|
return 30;
|
|
3507
3466
|
}
|
|
3467
|
+
function ArithmeticCalendarMonthCode(calendar, year, month) {
|
|
3468
|
+
const leap = calendar === "hebrew" && HebrewLeapYear(year);
|
|
3469
|
+
if (leap && month === 6) return "M05L";
|
|
3470
|
+
const code = month - Number(leap && month > 6);
|
|
3471
|
+
return "M" + (code < 10 ? "0" : "") + code;
|
|
3472
|
+
}
|
|
3473
|
+
function ArithmeticCalendarFromEpochDay(calendar, epoch) {
|
|
3474
|
+
const t = epoch * 864e5, civilYear = YearFromTime(t);
|
|
3475
|
+
if (IsISOCalendar(calendar)) {
|
|
3476
|
+
const year = civilYear - (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0), month = MonthFromTime(t) + 1;
|
|
3477
|
+
return {
|
|
3478
|
+
year,
|
|
3479
|
+
month,
|
|
3480
|
+
monthCode: ArithmeticCalendarMonthCode(calendar, year, month),
|
|
3481
|
+
day: DateFromTime(t)
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3484
|
+
const jd = epoch + 2440588;
|
|
3485
|
+
let year;
|
|
3486
|
+
switch (calendar) {
|
|
3487
|
+
case "coptic":
|
|
3488
|
+
year = Math.floor((4 * (jd - 1824665) + 3) / 1461);
|
|
3489
|
+
break;
|
|
3490
|
+
case "ethiopic":
|
|
3491
|
+
case "ethioaa":
|
|
3492
|
+
year = Math.floor((4 * (jd - 1723856) + 3) / 1461) + (calendar === "ethioaa" ? 5500 : 0);
|
|
3493
|
+
break;
|
|
3494
|
+
case "islamic-civil":
|
|
3495
|
+
case "islamic-tbla":
|
|
3496
|
+
year = Math.floor((30 * (jd - 1948440 + Number(calendar === "islamic-tbla")) + 10646) / 10631);
|
|
3497
|
+
break;
|
|
3498
|
+
case "persian":
|
|
3499
|
+
year = 1 + Math.floor((33 * (jd - 1948320) + 3) / 12053);
|
|
3500
|
+
break;
|
|
3501
|
+
case "indian":
|
|
3502
|
+
year = civilYear - 78;
|
|
3503
|
+
break;
|
|
3504
|
+
default: year = Math.floor((epoch + 2092590) * 492480 / 179876755) + 1;
|
|
3505
|
+
}
|
|
3506
|
+
while (ArithmeticCalendarStartOfYear(calendar, year) > epoch) year--;
|
|
3507
|
+
while (ArithmeticCalendarStartOfYear(calendar, year + 1) <= epoch) year++;
|
|
3508
|
+
let month = 1, remaining = epoch - ArithmeticCalendarStartOfYear(calendar, year);
|
|
3509
|
+
while (remaining >= ArithmeticCalendarDaysInMonth(calendar, year, month)) remaining -= ArithmeticCalendarDaysInMonth(calendar, year, month++);
|
|
3510
|
+
return {
|
|
3511
|
+
year,
|
|
3512
|
+
month,
|
|
3513
|
+
monthCode: ArithmeticCalendarMonthCode(calendar, year, month),
|
|
3514
|
+
day: remaining + 1
|
|
3515
|
+
};
|
|
3516
|
+
}
|
|
3517
|
+
const JapaneseEras = [
|
|
3518
|
+
[
|
|
3519
|
+
18017,
|
|
3520
|
+
"reiwa",
|
|
3521
|
+
2018
|
|
3522
|
+
],
|
|
3523
|
+
[
|
|
3524
|
+
6947,
|
|
3525
|
+
"heisei",
|
|
3526
|
+
1988
|
|
3527
|
+
],
|
|
3528
|
+
[
|
|
3529
|
+
-15713,
|
|
3530
|
+
"showa",
|
|
3531
|
+
1925
|
|
3532
|
+
],
|
|
3533
|
+
[
|
|
3534
|
+
-20974,
|
|
3535
|
+
"taisho",
|
|
3536
|
+
1911
|
|
3537
|
+
],
|
|
3538
|
+
[
|
|
3539
|
+
-35428,
|
|
3540
|
+
"meiji",
|
|
3541
|
+
1867
|
|
3542
|
+
]
|
|
3543
|
+
];
|
|
3544
|
+
function ArithmeticCalendarEra(calendar, epoch, year) {
|
|
3545
|
+
switch (calendar) {
|
|
3546
|
+
case "iso8601": return;
|
|
3547
|
+
case "buddhist": return {
|
|
3548
|
+
era: "be",
|
|
3549
|
+
eraYear: year
|
|
3550
|
+
};
|
|
3551
|
+
case "coptic":
|
|
3552
|
+
case "hebrew": return {
|
|
3553
|
+
era: "am",
|
|
3554
|
+
eraYear: year
|
|
3555
|
+
};
|
|
3556
|
+
case "ethiopic": return {
|
|
3557
|
+
era: year > 0 ? "am" : "aa",
|
|
3558
|
+
eraYear: year > 0 ? year : year + 5500
|
|
3559
|
+
};
|
|
3560
|
+
case "ethioaa": return {
|
|
3561
|
+
era: "aa",
|
|
3562
|
+
eraYear: year
|
|
3563
|
+
};
|
|
3564
|
+
case "indian": return {
|
|
3565
|
+
era: "shaka",
|
|
3566
|
+
eraYear: year
|
|
3567
|
+
};
|
|
3568
|
+
case "persian": return {
|
|
3569
|
+
era: "ap",
|
|
3570
|
+
eraYear: year
|
|
3571
|
+
};
|
|
3572
|
+
case "roc": return {
|
|
3573
|
+
era: year > 0 ? "roc" : "broc",
|
|
3574
|
+
eraYear: year > 0 ? year : 1 - year
|
|
3575
|
+
};
|
|
3576
|
+
case "islamic-civil":
|
|
3577
|
+
case "islamic-tbla": return {
|
|
3578
|
+
era: year > 0 ? "ah" : "bh",
|
|
3579
|
+
eraYear: year > 0 ? year : 1 - year
|
|
3580
|
+
};
|
|
3581
|
+
case "japanese": for (const [start, era, offset] of JapaneseEras) if (epoch >= start) return {
|
|
3582
|
+
era,
|
|
3583
|
+
eraYear: year - offset
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
return {
|
|
3587
|
+
era: year > 0 ? "ce" : "bce",
|
|
3588
|
+
eraYear: year > 0 ? year : 1 - year
|
|
3589
|
+
};
|
|
3590
|
+
}
|
|
3591
|
+
// packages/temporal/calendar.ts
|
|
3592
|
+
const calendarIds = [
|
|
3593
|
+
...arithmeticCalendars,
|
|
3594
|
+
"chinese",
|
|
3595
|
+
"dangi",
|
|
3596
|
+
"islamic-umalqura"
|
|
3597
|
+
];
|
|
3598
|
+
const mod = (value, divisor) => value - Math.floor(value / divisor) * divisor;
|
|
3599
|
+
function integer$2(value) {
|
|
3600
|
+
if (!Number.isSafeInteger(value)) throw new RangeError("Expected safe integer");
|
|
3601
|
+
return value;
|
|
3602
|
+
}
|
|
3603
|
+
function yearCheck(year) {
|
|
3604
|
+
if (Math.abs(integer$2(year)) > 4e5) throw new RangeError("Calendar year out of range");
|
|
3605
|
+
return year;
|
|
3606
|
+
}
|
|
3607
|
+
function dayCheck(day) {
|
|
3608
|
+
if (integer$2(day) < -100000001 || day > 1e8) throw new RangeError("Calendar date out of range");
|
|
3609
|
+
return day;
|
|
3610
|
+
}
|
|
3611
|
+
function calendarCheck(calendar) {
|
|
3612
|
+
if (!calendarIds.includes(calendar)) throw new RangeError("Unsupported calendar");
|
|
3613
|
+
}
|
|
3614
|
+
function overflowCheck(overflow) {
|
|
3615
|
+
if (overflow !== "constrain" && overflow !== "reject") throw new RangeError("Invalid overflow");
|
|
3616
|
+
}
|
|
3617
|
+
function regulate$1(value, min, max, overflow) {
|
|
3618
|
+
if (!Number.isInteger(value)) throw new RangeError("Expected finite integer");
|
|
3619
|
+
if (overflow === "reject" && (value < min || value > max)) throw new RangeError("Calendar field out of range");
|
|
3620
|
+
return Math.min(Math.max(value, min), max);
|
|
3621
|
+
}
|
|
3622
|
+
function start(calendar, year) {
|
|
3623
|
+
if (isLunisolar(calendar)) return tableYearStart(calendar, year);
|
|
3624
|
+
if (calendar === "islamic-umalqura") return tableYearStart(calendar, year) ?? ArithmeticCalendarStartOfYear("islamic-civil", year);
|
|
3625
|
+
return ArithmeticCalendarStartOfYear(calendar, year);
|
|
3626
|
+
}
|
|
3627
|
+
function calendarStartOfYear(calendar, year) {
|
|
3628
|
+
calendarCheck(calendar);
|
|
3629
|
+
yearCheck(year);
|
|
3630
|
+
const native = nativeTemporal();
|
|
3631
|
+
if (native) return native.calendarStartOfYear(calendar, year);
|
|
3632
|
+
return start(calendar, year);
|
|
3633
|
+
}
|
|
3634
|
+
function monthsInYear(calendar, year) {
|
|
3635
|
+
calendarCheck(calendar);
|
|
3636
|
+
yearCheck(year);
|
|
3637
|
+
const native = nativeTemporal();
|
|
3638
|
+
if (native) return native.calendarMonthsInYear(calendar, year);
|
|
3639
|
+
if (isLunisolar(calendar)) return tableLeapMonth(calendar, year) ? 13 : 12;
|
|
3640
|
+
return calendar === "islamic-umalqura" ? 12 : ArithmeticCalendarMonthsInYear(calendar, year);
|
|
3641
|
+
}
|
|
3642
|
+
function daysInMonth(calendar, year, month) {
|
|
3643
|
+
const native = nativeTemporal();
|
|
3644
|
+
if (native) return native.calendarDaysInMonth(calendar, year, month);
|
|
3645
|
+
const count = monthsInYear(calendar, year);
|
|
3646
|
+
if (integer$2(month) < 1 || month > count) throw new RangeError("Invalid calendar month");
|
|
3647
|
+
if (isLunisolar(calendar)) return tableMonthLength(calendar, year, month);
|
|
3648
|
+
if (calendar === "islamic-umalqura") return tableMonthLength(calendar, year, month) ?? daysInMonth("islamic-civil", year, month);
|
|
3649
|
+
return ArithmeticCalendarDaysInMonth(calendar, year, month);
|
|
3650
|
+
}
|
|
3508
3651
|
function monthCode(calendar, year, month) {
|
|
3509
3652
|
if (isLunisolar(calendar)) {
|
|
3510
3653
|
const leap = tableLeapMonth(calendar, year);
|
|
3511
3654
|
return "M" + String(month - Number(leap > 0 && month > leap)).padStart(2, "0") + (leap > 0 && month === leap + 1 ? "L" : "");
|
|
3512
3655
|
}
|
|
3513
|
-
|
|
3514
|
-
if (leap && month === 6) return "M05L";
|
|
3515
|
-
return "M" + String(month - Number(leap && month > 6)).padStart(2, "0");
|
|
3656
|
+
return ArithmeticCalendarMonthCode(calendar === "islamic-umalqura" ? "islamic-civil" : calendar, year, month);
|
|
3516
3657
|
}
|
|
3517
3658
|
function monthFromCode(calendar, year, code, overflow) {
|
|
3518
3659
|
if (isLunisolar(calendar)) {
|
|
@@ -3522,7 +3663,7 @@ function monthFromCode(calendar, year, code, overflow) {
|
|
|
3522
3663
|
return number + Number(leap > 0 && (number > leap || number === leap && code.endsWith("L")));
|
|
3523
3664
|
}
|
|
3524
3665
|
if (calendar === "hebrew" && code === "M05L") {
|
|
3525
|
-
if (!
|
|
3666
|
+
if (!HebrewLeapYear(year) && overflow === "reject") throw new RangeError("Leap month absent");
|
|
3526
3667
|
return 6;
|
|
3527
3668
|
}
|
|
3528
3669
|
if (!/^M(0[1-9]|1[0-3])$/.test(code) || code === "M13" && ![
|
|
@@ -3531,7 +3672,7 @@ function monthFromCode(calendar, year, code, overflow) {
|
|
|
3531
3672
|
"ethioaa"
|
|
3532
3673
|
].includes(calendar)) throw new RangeError("Invalid month code");
|
|
3533
3674
|
const month = Number(code.slice(1));
|
|
3534
|
-
return month + Number(calendar === "hebrew" &&
|
|
3675
|
+
return month + Number(calendar === "hebrew" && HebrewLeapYear(year) && month >= 6);
|
|
3535
3676
|
}
|
|
3536
3677
|
function calendarToEpochDayRaw(calendar, fields, overflow = "constrain") {
|
|
3537
3678
|
calendarCheck(calendar);
|
|
@@ -3573,39 +3714,9 @@ function calendarFromEpochDayRaw(calendar, epoch) {
|
|
|
3573
3714
|
monthCode: monthCode(calendar, value.year, value.month)
|
|
3574
3715
|
};
|
|
3575
3716
|
}
|
|
3576
|
-
|
|
3577
|
-
if (isoLike(calendar)) {
|
|
3578
|
-
const year = civilYear - (calendar === "buddhist" ? -543 : calendar === "roc" ? 1911 : 0), month = MonthFromTime(t) + 1;
|
|
3579
|
-
return {
|
|
3580
|
-
year,
|
|
3581
|
-
month,
|
|
3582
|
-
monthCode: monthCode(calendar, year, month),
|
|
3583
|
-
day: DateFromTime(t)
|
|
3584
|
-
};
|
|
3585
|
-
}
|
|
3717
|
+
if (calendar !== "islamic-umalqura") return ArithmeticCalendarFromEpochDay(calendar, epoch);
|
|
3586
3718
|
const jd = epoch + 2440588;
|
|
3587
|
-
let year;
|
|
3588
|
-
switch (calendar) {
|
|
3589
|
-
case "coptic":
|
|
3590
|
-
year = Math.floor((4 * (jd - 1824665) + 3) / 1461);
|
|
3591
|
-
break;
|
|
3592
|
-
case "ethiopic":
|
|
3593
|
-
case "ethioaa":
|
|
3594
|
-
year = Math.floor((4 * (jd - 1723856) + 3) / 1461) + (calendar === "ethioaa" ? 5500 : 0);
|
|
3595
|
-
break;
|
|
3596
|
-
case "islamic-umalqura":
|
|
3597
|
-
case "islamic-civil":
|
|
3598
|
-
case "islamic-tbla":
|
|
3599
|
-
year = Math.floor((30 * (jd - 1948440 + Number(calendar === "islamic-tbla")) + 10646) / 10631);
|
|
3600
|
-
break;
|
|
3601
|
-
case "persian":
|
|
3602
|
-
year = 1 + Math.floor((33 * (jd - 1948320) + 3) / 12053);
|
|
3603
|
-
break;
|
|
3604
|
-
case "indian":
|
|
3605
|
-
year = civilYear - 78;
|
|
3606
|
-
break;
|
|
3607
|
-
default: year = Math.floor((epoch + 2092590) * 492480 / 179876755) + 1;
|
|
3608
|
-
}
|
|
3719
|
+
let year = Math.floor((30 * (jd - 1948440) + 10646) / 10631);
|
|
3609
3720
|
while (start(calendar, year) > epoch) year--;
|
|
3610
3721
|
while (start(calendar, year + 1) <= epoch) year++;
|
|
3611
3722
|
let month = 1, remaining = epoch - start(calendar, year);
|
|
@@ -3631,11 +3742,11 @@ function addYearMonth(calendar, original, years, months, overflow) {
|
|
|
3631
3742
|
month = mod(serial, count) + 1;
|
|
3632
3743
|
} else {
|
|
3633
3744
|
month = monthFromCode(calendar, year, original.monthCode, overflow);
|
|
3634
|
-
const serial = integer$2(
|
|
3745
|
+
const serial = integer$2(HebrewElapsedMonths(year) + month - 1 + months);
|
|
3635
3746
|
year = yearCheck(Math.floor((19 * serial + 234) / 235));
|
|
3636
|
-
while (
|
|
3637
|
-
while (
|
|
3638
|
-
month = serial -
|
|
3747
|
+
while (HebrewElapsedMonths(year) > serial) year--;
|
|
3748
|
+
while (HebrewElapsedMonths(year + 1) <= serial) year++;
|
|
3749
|
+
month = serial - HebrewElapsedMonths(year) + 1;
|
|
3639
3750
|
}
|
|
3640
3751
|
return {
|
|
3641
3752
|
year,
|
|
@@ -3671,7 +3782,7 @@ function calendarMonthSerial(calendar, year, month) {
|
|
|
3671
3782
|
const native = nativeTemporal();
|
|
3672
3783
|
if (native) return native.calendarMonthSerial(calendar, year, month);
|
|
3673
3784
|
if (isLunisolar(calendar)) return tableMonthSerial(calendar, year, month);
|
|
3674
|
-
return calendar === "hebrew" ?
|
|
3785
|
+
return calendar === "hebrew" ? HebrewElapsedMonths(year) + month - 1 : year * monthsInYear(calendar, year) + month - 1;
|
|
3675
3786
|
}
|
|
3676
3787
|
function calendarDateUntilRaw(calendar, one, two, largest) {
|
|
3677
3788
|
const native = nativeTemporal();
|
|
@@ -3709,33 +3820,6 @@ function calendarDateUntilRaw(calendar, one, two, largest) {
|
|
|
3709
3820
|
}
|
|
3710
3821
|
return result;
|
|
3711
3822
|
}
|
|
3712
|
-
const japaneseEras = [
|
|
3713
|
-
[
|
|
3714
|
-
18017,
|
|
3715
|
-
"reiwa",
|
|
3716
|
-
2018
|
|
3717
|
-
],
|
|
3718
|
-
[
|
|
3719
|
-
6947,
|
|
3720
|
-
"heisei",
|
|
3721
|
-
1988
|
|
3722
|
-
],
|
|
3723
|
-
[
|
|
3724
|
-
-15713,
|
|
3725
|
-
"showa",
|
|
3726
|
-
1925
|
|
3727
|
-
],
|
|
3728
|
-
[
|
|
3729
|
-
-20974,
|
|
3730
|
-
"taisho",
|
|
3731
|
-
1911
|
|
3732
|
-
],
|
|
3733
|
-
[
|
|
3734
|
-
-35428,
|
|
3735
|
-
"meiji",
|
|
3736
|
-
1867
|
|
3737
|
-
]
|
|
3738
|
-
];
|
|
3739
3823
|
function calendarEra(calendar, epoch, extended = false) {
|
|
3740
3824
|
const native = nativeTemporal();
|
|
3741
3825
|
if (native) {
|
|
@@ -3743,54 +3827,8 @@ function calendarEra(calendar, epoch, extended = false) {
|
|
|
3743
3827
|
return native.calendarEra(calendar, epoch);
|
|
3744
3828
|
}
|
|
3745
3829
|
const { year } = (extended ? calendarFromEpochDayRaw : calendarFromEpochDay)(calendar, epoch);
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
case "chinese":
|
|
3749
|
-
case "dangi": return;
|
|
3750
|
-
case "buddhist": return {
|
|
3751
|
-
era: "be",
|
|
3752
|
-
eraYear: year
|
|
3753
|
-
};
|
|
3754
|
-
case "coptic":
|
|
3755
|
-
case "hebrew": return {
|
|
3756
|
-
era: "am",
|
|
3757
|
-
eraYear: year
|
|
3758
|
-
};
|
|
3759
|
-
case "ethiopic": return {
|
|
3760
|
-
era: year > 0 ? "am" : "aa",
|
|
3761
|
-
eraYear: year > 0 ? year : year + 5500
|
|
3762
|
-
};
|
|
3763
|
-
case "ethioaa": return {
|
|
3764
|
-
era: "aa",
|
|
3765
|
-
eraYear: year
|
|
3766
|
-
};
|
|
3767
|
-
case "indian": return {
|
|
3768
|
-
era: "shaka",
|
|
3769
|
-
eraYear: year
|
|
3770
|
-
};
|
|
3771
|
-
case "persian": return {
|
|
3772
|
-
era: "ap",
|
|
3773
|
-
eraYear: year
|
|
3774
|
-
};
|
|
3775
|
-
case "roc": return {
|
|
3776
|
-
era: year > 0 ? "roc" : "broc",
|
|
3777
|
-
eraYear: year > 0 ? year : 1 - year
|
|
3778
|
-
};
|
|
3779
|
-
case "islamic-umalqura":
|
|
3780
|
-
case "islamic-civil":
|
|
3781
|
-
case "islamic-tbla": return {
|
|
3782
|
-
era: year > 0 ? "ah" : "bh",
|
|
3783
|
-
eraYear: year > 0 ? year : 1 - year
|
|
3784
|
-
};
|
|
3785
|
-
case "japanese": for (const [start, era, offset] of japaneseEras) if (epoch >= start) return {
|
|
3786
|
-
era,
|
|
3787
|
-
eraYear: year - offset
|
|
3788
|
-
};
|
|
3789
|
-
}
|
|
3790
|
-
return {
|
|
3791
|
-
era: year > 0 ? "ce" : "bce",
|
|
3792
|
-
eraYear: year > 0 ? year : 1 - year
|
|
3793
|
-
};
|
|
3830
|
+
if (calendar === "chinese" || calendar === "dangi") return void 0;
|
|
3831
|
+
return ArithmeticCalendarEra(calendar === "islamic-umalqura" ? "islamic-civil" : calendar, epoch, year);
|
|
3794
3832
|
}
|
|
3795
3833
|
function calendarYearFromEra(calendar, era, eraYear) {
|
|
3796
3834
|
calendarCheck(calendar);
|
|
@@ -3798,7 +3836,7 @@ function calendarYearFromEra(calendar, era, eraYear) {
|
|
|
3798
3836
|
const native = nativeTemporal();
|
|
3799
3837
|
if (native) return native.calendarYearFromEra(calendar, era, eraYear);
|
|
3800
3838
|
if (calendar === "japanese") {
|
|
3801
|
-
for (const [, name, offset] of
|
|
3839
|
+
for (const [, name, offset] of JapaneseEras) if (era === name) return yearCheck(eraYear + offset);
|
|
3802
3840
|
}
|
|
3803
3841
|
if (calendar === "ethiopic" && era === "aa") return yearCheck(eraYear - 5500);
|
|
3804
3842
|
const names = {
|
|
@@ -3821,7 +3859,7 @@ function calendarYearFromEra(calendar, era, eraYear) {
|
|
|
3821
3859
|
if (index < 0) throw new RangeError("Invalid era");
|
|
3822
3860
|
return yearCheck(index === 1 ? 1 - eraYear : eraYear);
|
|
3823
3861
|
}
|
|
3824
|
-
//
|
|
3862
|
+
// packages/temporal/legacy-lunisolar-date.ts
|
|
3825
3863
|
const Constructor$1 = globalThis.Intl?.DateTimeFormat;
|
|
3826
3864
|
const nativeParts$1 = Constructor$1?.prototype.formatToParts;
|
|
3827
3865
|
const NumberConstructor$3 = globalThis.Intl?.NumberFormat;
|
|
@@ -3974,7 +4012,7 @@ function correctLunisolarParts(value, raw, resolved, surrogateMilliseconds, expe
|
|
|
3974
4012
|
value: changes.get(item.type)
|
|
3975
4013
|
} : item) : raw;
|
|
3976
4014
|
}
|
|
3977
|
-
//
|
|
4015
|
+
// packages/temporal/legacy-calendar-date.ts
|
|
3978
4016
|
const Constructor = globalThis.Intl?.DateTimeFormat;
|
|
3979
4017
|
const NumberConstructor$2 = globalThis.Intl?.NumberFormat;
|
|
3980
4018
|
const numberFormat$2 = NumberConstructor$2 && Object.getOwnPropertyDescriptor(NumberConstructor$2.prototype, "format")?.get;
|
|
@@ -4195,7 +4233,7 @@ function restoreCalendarParts(value, raw, epoch, labels, options, parts) {
|
|
|
4195
4233
|
value: changes.get(part.type)
|
|
4196
4234
|
} : part);
|
|
4197
4235
|
}
|
|
4198
|
-
//
|
|
4236
|
+
// packages/temporal/legacy-extended-date.ts
|
|
4199
4237
|
const legacyTimeZoneName = Symbol();
|
|
4200
4238
|
const limit$2 = 864e13;
|
|
4201
4239
|
const cycle = 146097 * 864e5;
|
|
@@ -4251,7 +4289,7 @@ function legacyDateTimeFormat(value, format, parts, resolved) {
|
|
|
4251
4289
|
}
|
|
4252
4290
|
return legacyDateTimeParts(value, parts, resolved).map((part) => part.value).join("");
|
|
4253
4291
|
}
|
|
4254
|
-
//
|
|
4292
|
+
// packages/temporal/legacy-zoned-date.ts
|
|
4255
4293
|
const zones = /* @__PURE__ */ new WeakMap();
|
|
4256
4294
|
const NumberConstructor = globalThis.Intl?.NumberFormat;
|
|
4257
4295
|
const numberFormat = NumberConstructor && Object.getOwnPropertyDescriptor(NumberConstructor.prototype, "format")?.get;
|
|
@@ -4311,7 +4349,7 @@ function offsetName(Constructor, resolved, offset, long, parts) {
|
|
|
4311
4349
|
const replacement = number(hour) + (long || minute || second ? separator + two(minute) : "") + (second ? separator + two(second) : "");
|
|
4312
4350
|
return pattern.replace(/0?1(?:\D+00)?/, replacement);
|
|
4313
4351
|
}
|
|
4314
|
-
//
|
|
4352
|
+
// packages/temporal/locale.ts
|
|
4315
4353
|
const dateUTC = Date.UTC;
|
|
4316
4354
|
let dateTimeConstructor = globalThis.Intl?.DateTimeFormat;
|
|
4317
4355
|
let temporalFormat = dateTimeConstructor?.__formatTemporal;
|
|
@@ -4494,7 +4532,7 @@ function legacyDateTimeOption(key, value) {
|
|
|
4494
4532
|
if (key === "fractionalSecondDigits") return +value;
|
|
4495
4533
|
return ToString(value);
|
|
4496
4534
|
}
|
|
4497
|
-
//
|
|
4535
|
+
// packages/temporal/instant-string.ts
|
|
4498
4536
|
function parseOffsetNanoseconds(value, annotation = false) {
|
|
4499
4537
|
const match = /^([+-])(\d{2})(?:(:?)(\d{2})(?:\3(\d{2})(?:[.,](\d{1,9}))?)?)?$/.exec(value);
|
|
4500
4538
|
if (!match || match[0] !== value || annotation && match[5] !== void 0) throw new RangeError("Invalid UTC offset");
|
|
@@ -4712,7 +4750,7 @@ function parseZonedDateTimeString(value) {
|
|
|
4712
4750
|
offset: /[Tt ]/.test(body) ? offset : void 0
|
|
4713
4751
|
};
|
|
4714
4752
|
}
|
|
4715
|
-
//
|
|
4753
|
+
// packages/temporal/zones.ts
|
|
4716
4754
|
const cache = /* @__PURE__ */ new Map();
|
|
4717
4755
|
function typescriptTimeZone(name) {
|
|
4718
4756
|
{
|
|
@@ -4834,7 +4872,7 @@ function primaryTimeZoneIdentifier(id) {
|
|
|
4834
4872
|
function timeZoneEquals(one, two) {
|
|
4835
4873
|
return primaryTimeZoneIdentifier(one) === primaryTimeZoneIdentifier(two);
|
|
4836
4874
|
}
|
|
4837
|
-
//
|
|
4875
|
+
// packages/temporal/plain-slots.ts
|
|
4838
4876
|
const dates = /* @__PURE__ */ new WeakMap();
|
|
4839
4877
|
const dateTimes = /* @__PURE__ */ new WeakMap();
|
|
4840
4878
|
const times = /* @__PURE__ */ new WeakMap();
|
|
@@ -4860,7 +4898,7 @@ function getZonedDateTimeSlot(value) {
|
|
|
4860
4898
|
calendar: slot.calendar
|
|
4861
4899
|
};
|
|
4862
4900
|
}
|
|
4863
|
-
//
|
|
4901
|
+
// packages/temporal/accessors.ts
|
|
4864
4902
|
function defineGetters(prototype, names, read) {
|
|
4865
4903
|
function define(name, index) {
|
|
4866
4904
|
Object.defineProperty(prototype, name, {
|
|
@@ -4873,7 +4911,7 @@ function defineGetters(prototype, names, read) {
|
|
|
4873
4911
|
}
|
|
4874
4912
|
for (let index = 0; index < names.length; index++) define(names[index], index);
|
|
4875
4913
|
}
|
|
4876
|
-
//
|
|
4914
|
+
// packages/ecma262-abstract/ToPrimitive.js
|
|
4877
4915
|
function IsPrimitive(value) {
|
|
4878
4916
|
return value === null || typeof value !== "object" && typeof value !== "function";
|
|
4879
4917
|
}
|
|
@@ -4919,7 +4957,7 @@ function ToPrimitive(input, preferredType) {
|
|
|
4919
4957
|
}
|
|
4920
4958
|
return input;
|
|
4921
4959
|
}
|
|
4922
|
-
//
|
|
4960
|
+
// packages/temporal/instant-format.ts
|
|
4923
4961
|
function formatInstant(value, precision = "auto", offset) {
|
|
4924
4962
|
const fields = epochNanosecondsToISO(value + (offset ?? 0n));
|
|
4925
4963
|
const pad = (value, length = 2) => String(value).padStart(length, "0");
|
|
@@ -4935,7 +4973,7 @@ function formatInstant(value, precision = "auto", offset) {
|
|
|
4935
4973
|
const minutes = Number((absolute + 30000000000n) / 60000000000n);
|
|
4936
4974
|
return result + (offset < 0n && minutes !== 0 ? "-" : "+") + pad(Math.floor(minutes / 60)) + ":" + pad(minutes % 60);
|
|
4937
4975
|
}
|
|
4938
|
-
//
|
|
4976
|
+
// packages/temporal/duration-core.ts
|
|
4939
4977
|
const durationFieldNames = [
|
|
4940
4978
|
"years",
|
|
4941
4979
|
"months",
|
|
@@ -5096,7 +5134,7 @@ function durationTotalNumber(nanoseconds, divisor) {
|
|
|
5096
5134
|
const value = Number(mantissa) * 2 ** (exponent - 52);
|
|
5097
5135
|
return negative ? -value : value;
|
|
5098
5136
|
}
|
|
5099
|
-
//
|
|
5137
|
+
// packages/temporal/duration-format.ts
|
|
5100
5138
|
function formatDuration(fields, digits = "auto") {
|
|
5101
5139
|
const native = nativeTemporal();
|
|
5102
5140
|
if (native) return native.formatDuration(fields, digits, "trunc");
|
|
@@ -5126,7 +5164,7 @@ function formatDuration(fields, digits = "auto") {
|
|
|
5126
5164
|
if (secondNs !== 0n || digits !== "auto" || (result === "P" || result === "-P") && time === "") time += String(secondNs / 1000000000n) + (decimals ? "." + decimals : "") + "S";
|
|
5127
5165
|
return result + (time ? "T" + time : "");
|
|
5128
5166
|
}
|
|
5129
|
-
//
|
|
5167
|
+
// packages/temporal/rounding.ts
|
|
5130
5168
|
const timeUnitNanoseconds = {
|
|
5131
5169
|
hour: 3600000000000n,
|
|
5132
5170
|
minute: 60000000000n,
|
|
@@ -5233,7 +5271,7 @@ function roundDuration(value, quantum, mode) {
|
|
|
5233
5271
|
halfEven: "halfEven"
|
|
5234
5272
|
}[mode]);
|
|
5235
5273
|
}
|
|
5236
|
-
//
|
|
5274
|
+
// packages/temporal/date-core.ts
|
|
5237
5275
|
const nsPerDay = 86400000000000n;
|
|
5238
5276
|
const clockNames = [
|
|
5239
5277
|
"hour",
|
|
@@ -5671,7 +5709,7 @@ function roundRelativeDifference(start, end, largest, smallest, increment, mode,
|
|
|
5671
5709
|
}
|
|
5672
5710
|
return result;
|
|
5673
5711
|
}
|
|
5674
|
-
//
|
|
5712
|
+
// packages/temporal/plain-date-time.ts
|
|
5675
5713
|
function read$7(item) {
|
|
5676
5714
|
const slot = getDateTimeSlot(item);
|
|
5677
5715
|
if (!slot) throw new TypeError("Invalid PlainDateTime receiver");
|
|
@@ -5895,7 +5933,7 @@ defineGetters(PlainDateTimeValue.prototype, [...datePropertyNames, ...clockNames
|
|
|
5895
5933
|
const slot = read$7(receiver), index = clockNames.indexOf(name);
|
|
5896
5934
|
return index < 0 ? dateProperty(dateSlot(slot), name) : Number(timeOf(slot.epochNanoseconds) / clockFactors[index] % BigInt(clockBounds[index] + 1));
|
|
5897
5935
|
});
|
|
5898
|
-
//
|
|
5936
|
+
// packages/temporal/short-date-core.ts
|
|
5899
5937
|
function shortCalendar(calendar) {
|
|
5900
5938
|
return calendar;
|
|
5901
5939
|
}
|
|
@@ -6035,7 +6073,7 @@ function mergeShortFields(slot, partial, kind = "year-month") {
|
|
|
6035
6073
|
else delete fields.day;
|
|
6036
6074
|
return mergeDateFields(slot.calendar, fields, partial);
|
|
6037
6075
|
}
|
|
6038
|
-
//
|
|
6076
|
+
// packages/temporal/plain-year-month.ts
|
|
6039
6077
|
function read$6(item) {
|
|
6040
6078
|
const slot = getYearMonthSlot(item);
|
|
6041
6079
|
if (!slot) throw new TypeError("Invalid PlainYearMonth receiver");
|
|
@@ -6221,7 +6259,7 @@ defineGetters(PlainYearMonthValue.prototype, [
|
|
|
6221
6259
|
"monthsInYear",
|
|
6222
6260
|
"inLeapYear"
|
|
6223
6261
|
], (receiver, name) => dateProperty(read$6(receiver), name, true));
|
|
6224
|
-
//
|
|
6262
|
+
// packages/temporal/plain-month-day.ts
|
|
6225
6263
|
function read$5(item) {
|
|
6226
6264
|
const slot = getMonthDaySlot(item);
|
|
6227
6265
|
if (!slot) throw new TypeError("Invalid PlainMonthDay receiver");
|
|
@@ -6329,7 +6367,7 @@ defineGetters(PlainMonthDayValue.prototype, [
|
|
|
6329
6367
|
"monthCode",
|
|
6330
6368
|
"day"
|
|
6331
6369
|
], (receiver, name) => dateProperty(read$5(receiver), name, true));
|
|
6332
|
-
//
|
|
6370
|
+
// packages/temporal/plain-date.ts
|
|
6333
6371
|
function read$4(item) {
|
|
6334
6372
|
const slot = getDateSlot(item);
|
|
6335
6373
|
if (!slot) throw new TypeError("Invalid PlainDate receiver");
|
|
@@ -6510,7 +6548,7 @@ Object.defineProperties(PlainDateValue.prototype, {
|
|
|
6510
6548
|
}
|
|
6511
6549
|
});
|
|
6512
6550
|
defineGetters(PlainDateValue.prototype, datePropertyNames, (receiver, name) => dateProperty(read$4(receiver), name));
|
|
6513
|
-
//
|
|
6551
|
+
// packages/temporal/relative-duration.ts
|
|
6514
6552
|
function toRelativeTo(value) {
|
|
6515
6553
|
if (value === void 0) return void 0;
|
|
6516
6554
|
const zoned = getZonedSlot(value), date = getDateSlot(value);
|
|
@@ -6651,7 +6689,7 @@ function relativeRound(fields, relative, largest, smallest, increment, mode) {
|
|
|
6651
6689
|
}
|
|
6652
6690
|
return roundedDateTimeDifference(start, end, relative.date.calendar, largest, smallest, increment, mode, false);
|
|
6653
6691
|
}
|
|
6654
|
-
//
|
|
6692
|
+
// packages/temporal/duration.ts
|
|
6655
6693
|
const slots$1 = /* @__PURE__ */ new WeakMap();
|
|
6656
6694
|
const getSlot$1 = slots$1.get.bind(slots$1);
|
|
6657
6695
|
const setSlot$1 = slots$1.set.bind(slots$1);
|
|
@@ -6866,7 +6904,7 @@ Object.defineProperties(DurationValue.prototype, {
|
|
|
6866
6904
|
configurable: true
|
|
6867
6905
|
}
|
|
6868
6906
|
});
|
|
6869
|
-
//
|
|
6907
|
+
// packages/temporal/plain-time.ts
|
|
6870
6908
|
const names = [
|
|
6871
6909
|
"hour",
|
|
6872
6910
|
"minute",
|
|
@@ -7098,7 +7136,7 @@ Object.defineProperties(PlainTimeValue.prototype, {
|
|
|
7098
7136
|
}
|
|
7099
7137
|
});
|
|
7100
7138
|
defineGetters(PlainTimeValue.prototype, names, (receiver, _name, index) => fields(read$2(receiver))[index]);
|
|
7101
|
-
//
|
|
7139
|
+
// packages/temporal/zoned-date-time.ts
|
|
7102
7140
|
function read$1(value) {
|
|
7103
7141
|
const slot = getZonedSlot(value);
|
|
7104
7142
|
if (!slot) throw new TypeError("Invalid ZonedDateTime receiver");
|
|
@@ -7564,7 +7602,7 @@ defineGetters(ZonedDateTimeValue.prototype, [...datePropertyNames, ...clockNames
|
|
|
7564
7602
|
calendar: slot.calendar
|
|
7565
7603
|
}, name);
|
|
7566
7604
|
});
|
|
7567
|
-
//
|
|
7605
|
+
// packages/temporal/instant.ts
|
|
7568
7606
|
function instantString(value, precision = "auto", offset) {
|
|
7569
7607
|
const native = nativeTemporal();
|
|
7570
7608
|
return native ? native.formatInstant(value, precision, offset) : formatInstant(value, precision, offset);
|
|
@@ -7737,7 +7775,7 @@ Object.defineProperties(InstantValue.prototype, {
|
|
|
7737
7775
|
configurable: true
|
|
7738
7776
|
}
|
|
7739
7777
|
});
|
|
7740
|
-
//
|
|
7778
|
+
// packages/temporal/now.ts
|
|
7741
7779
|
const limit = 8640000000000000000000n;
|
|
7742
7780
|
function createNow(clock) {
|
|
7743
7781
|
function instant() {
|
|
@@ -7801,16 +7839,16 @@ const Now = createNow({
|
|
|
7801
7839
|
epochNanoseconds: () => systemClock.epochNanoseconds(),
|
|
7802
7840
|
timeZoneId: () => systemClock.timeZoneId()
|
|
7803
7841
|
});
|
|
7804
|
-
//
|
|
7842
|
+
// packages/temporal/date-bridge.ts
|
|
7805
7843
|
const getTime = Function.prototype.call.bind(Date.prototype.getTime);
|
|
7806
7844
|
function createDateToTemporalInstant(create) {
|
|
7807
7845
|
return { toTemporalInstant() {
|
|
7808
7846
|
return create(BigInt(getTime(this)) * 1000000n);
|
|
7809
7847
|
} }.toTemporalInstant;
|
|
7810
7848
|
}
|
|
7811
|
-
//
|
|
7849
|
+
// packages/temporal/date-to-temporal-instant.ts
|
|
7812
7850
|
const toTemporalInstant = createDateToTemporalInstant(createInstant);
|
|
7813
|
-
//
|
|
7851
|
+
// packages/temporal/index.ts
|
|
7814
7852
|
const Temporal = Object.defineProperties({}, {
|
|
7815
7853
|
Now: {
|
|
7816
7854
|
value: Now,
|