@formatjs/intl-durationformat 0.10.18 → 0.11.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.d.ts +15 -14
- package/index.js +266 -218
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/polyfill-force.d.ts +1 -1
- package/polyfill-force.js +266 -220
- package/polyfill-force.js.map +1 -1
- package/polyfill.d.ts +1 -1
- package/polyfill.js +266 -218
- package/polyfill.js.map +1 -1
- package/should-polyfill.d.ts +1 -2
package/polyfill.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/polyfill.js
CHANGED
|
@@ -1,14 +1,121 @@
|
|
|
1
1
|
import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
|
|
2
2
|
import { BigDecimal, Decimal } from "@formatjs/bigdecimal";
|
|
3
|
+
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
|
|
4
|
+
const numberingSystemNames = [
|
|
5
|
+
"adlm",
|
|
6
|
+
"ahom",
|
|
7
|
+
"arab",
|
|
8
|
+
"arabext",
|
|
9
|
+
"armn",
|
|
10
|
+
"armnlow",
|
|
11
|
+
"bali",
|
|
12
|
+
"beng",
|
|
13
|
+
"bhks",
|
|
14
|
+
"brah",
|
|
15
|
+
"cakm",
|
|
16
|
+
"cham",
|
|
17
|
+
"cyrl",
|
|
18
|
+
"deva",
|
|
19
|
+
"diak",
|
|
20
|
+
"ethi",
|
|
21
|
+
"fullwide",
|
|
22
|
+
"gara",
|
|
23
|
+
"geor",
|
|
24
|
+
"gong",
|
|
25
|
+
"gonm",
|
|
26
|
+
"grek",
|
|
27
|
+
"greklow",
|
|
28
|
+
"gujr",
|
|
29
|
+
"gukh",
|
|
30
|
+
"guru",
|
|
31
|
+
"hanidays",
|
|
32
|
+
"hanidec",
|
|
33
|
+
"hans",
|
|
34
|
+
"hansfin",
|
|
35
|
+
"hant",
|
|
36
|
+
"hantfin",
|
|
37
|
+
"hebr",
|
|
38
|
+
"hmng",
|
|
39
|
+
"hmnp",
|
|
40
|
+
"java",
|
|
41
|
+
"jpan",
|
|
42
|
+
"jpanfin",
|
|
43
|
+
"jpanyear",
|
|
44
|
+
"kali",
|
|
45
|
+
"kawi",
|
|
46
|
+
"khmr",
|
|
47
|
+
"knda",
|
|
48
|
+
"krai",
|
|
49
|
+
"lana",
|
|
50
|
+
"lanatham",
|
|
51
|
+
"laoo",
|
|
52
|
+
"latn",
|
|
53
|
+
"lepc",
|
|
54
|
+
"limb",
|
|
55
|
+
"mathbold",
|
|
56
|
+
"mathdbl",
|
|
57
|
+
"mathmono",
|
|
58
|
+
"mathsanb",
|
|
59
|
+
"mathsans",
|
|
60
|
+
"mlym",
|
|
61
|
+
"modi",
|
|
62
|
+
"mong",
|
|
63
|
+
"mroo",
|
|
64
|
+
"mtei",
|
|
65
|
+
"mymr",
|
|
66
|
+
"mymrepka",
|
|
67
|
+
"mymrpao",
|
|
68
|
+
"mymrshan",
|
|
69
|
+
"mymrtlng",
|
|
70
|
+
"nagm",
|
|
71
|
+
"newa",
|
|
72
|
+
"nkoo",
|
|
73
|
+
"olck",
|
|
74
|
+
"onao",
|
|
75
|
+
"orya",
|
|
76
|
+
"osma",
|
|
77
|
+
"outlined",
|
|
78
|
+
"rohg",
|
|
79
|
+
"roman",
|
|
80
|
+
"romanlow",
|
|
81
|
+
"saur",
|
|
82
|
+
"segment",
|
|
83
|
+
"shrd",
|
|
84
|
+
"sind",
|
|
85
|
+
"sinh",
|
|
86
|
+
"sora",
|
|
87
|
+
"sund",
|
|
88
|
+
"sunu",
|
|
89
|
+
"takr",
|
|
90
|
+
"talu",
|
|
91
|
+
"taml",
|
|
92
|
+
"tamldec",
|
|
93
|
+
"telu",
|
|
94
|
+
"thai",
|
|
95
|
+
"tibt",
|
|
96
|
+
"tirh",
|
|
97
|
+
"tnsa",
|
|
98
|
+
"tols",
|
|
99
|
+
"vaii",
|
|
100
|
+
"wara",
|
|
101
|
+
"wcho"
|
|
102
|
+
];
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
|
|
105
|
+
/** Tests the Unicode locale identifier `type` grammar, not locale support. */
|
|
106
|
+
function IsUnicodeLocaleIdentifierType(value) {
|
|
107
|
+
return /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i.test(value);
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
3
110
|
//#region packages/ecma262-abstract/OrdinaryHasInstance.js
|
|
4
|
-
function IsCallable
|
|
111
|
+
function IsCallable(fn) {
|
|
5
112
|
return typeof fn === "function";
|
|
6
113
|
}
|
|
7
114
|
/**
|
|
8
115
|
* https://tc39.es/ecma262/#sec-ordinaryhasinstance
|
|
9
116
|
*/
|
|
10
117
|
function OrdinaryHasInstance(C, O, internalSlots) {
|
|
11
|
-
if (!IsCallable
|
|
118
|
+
if (!IsCallable(C)) return false;
|
|
12
119
|
if (internalSlots?.boundTargetFunction) return O instanceof internalSlots?.boundTargetFunction;
|
|
13
120
|
if (typeof O !== "object") return false;
|
|
14
121
|
let P = C.prototype;
|
|
@@ -36,7 +143,9 @@ function CanonicalizeLocaleList(locales) {
|
|
|
36
143
|
//#endregion
|
|
37
144
|
//#region packages/ecma402-abstract/DefaultNumberOption.js
|
|
38
145
|
/**
|
|
146
|
+
* ECMA-402 §9.2.13 DefaultNumberOption, step 2.
|
|
39
147
|
* https://tc39.es/ecma402/#sec-defaultnumberoption
|
|
148
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
|
|
40
149
|
* @param val
|
|
41
150
|
* @param min
|
|
42
151
|
* @param max
|
|
@@ -44,7 +153,7 @@ function CanonicalizeLocaleList(locales) {
|
|
|
44
153
|
*/
|
|
45
154
|
function DefaultNumberOption(inputVal, min, max, fallback) {
|
|
46
155
|
if (inputVal === void 0) return fallback;
|
|
47
|
-
const val =
|
|
156
|
+
const val = +inputVal;
|
|
48
157
|
if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
|
|
49
158
|
return Math.floor(val);
|
|
50
159
|
}
|
|
@@ -82,7 +191,7 @@ function ToString(o) {
|
|
|
82
191
|
* @param fallback
|
|
83
192
|
*/
|
|
84
193
|
function GetOption(opts, prop, type, values, fallback) {
|
|
85
|
-
if (typeof opts !== "object") throw new TypeError("Options must be an object");
|
|
194
|
+
if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
|
|
86
195
|
let value = opts[prop];
|
|
87
196
|
if (value !== void 0) {
|
|
88
197
|
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
|
|
@@ -195,7 +304,7 @@ function ensureIntl() {
|
|
|
195
304
|
});
|
|
196
305
|
return Intl;
|
|
197
306
|
}
|
|
198
|
-
function invariant
|
|
307
|
+
function invariant(condition, message, Err = Error) {
|
|
199
308
|
if (!condition) throw new Err(message);
|
|
200
309
|
}
|
|
201
310
|
const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
@@ -206,24 +315,28 @@ const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...arg
|
|
|
206
315
|
function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
|
|
207
316
|
let style = GetOption(options, unit, "string", stylesList, void 0);
|
|
208
317
|
let displayDefault = "always";
|
|
209
|
-
if (style === void 0)
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (prevStyle === "numeric" || prevStyle === "2-digit") {
|
|
220
|
-
if (style !== "numeric" && style !== "2-digit") throw new RangeError("Can't mix numeric and non-numeric styles");
|
|
221
|
-
else if (unit === "minutes" || unit === "seconds") style = "2-digit";
|
|
222
|
-
if (style === "numeric" && (unit === "milliseconds" || unit === "microseconds" || unit === "nanoseconds")) {
|
|
223
|
-
if (display === "always") throw new RangeError("Can't display milliseconds, microseconds, or nanoseconds in numeric format");
|
|
224
|
-
style = "fractional";
|
|
318
|
+
if (style === void 0) {
|
|
319
|
+
if (baseStyle === "digital") {
|
|
320
|
+
style = digitalBase;
|
|
321
|
+
if (unit !== "hours" && unit !== "minutes" && unit !== "seconds") displayDefault = "auto";
|
|
322
|
+
} else if (prevStyle === "fractional" || prevStyle === "numeric" || prevStyle === "2-digit") {
|
|
323
|
+
style = "numeric";
|
|
324
|
+
if (unit !== "minutes" && unit !== "seconds") displayDefault = "auto";
|
|
325
|
+
} else {
|
|
326
|
+
style = baseStyle;
|
|
327
|
+
displayDefault = "auto";
|
|
225
328
|
}
|
|
226
329
|
}
|
|
330
|
+
if (style === "numeric" && (unit === "milliseconds" || unit === "microseconds" || unit === "nanoseconds")) {
|
|
331
|
+
style = "fractional";
|
|
332
|
+
displayDefault = "auto";
|
|
333
|
+
}
|
|
334
|
+
const display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
|
|
335
|
+
if (display === "always" && style === "fractional") throw new RangeError("Fractional units cannot use always display");
|
|
336
|
+
if (prevStyle === "fractional" && style !== "fractional") throw new RangeError("Fractional units must be followed by fractional units");
|
|
337
|
+
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeError("Can't mix numeric and non-numeric styles");
|
|
338
|
+
if (twoDigitHours && unit === "hours") style = "2-digit";
|
|
339
|
+
if ((unit === "minutes" || unit === "seconds") && (prevStyle === "numeric" || prevStyle === "2-digit")) style = "2-digit";
|
|
227
340
|
return {
|
|
228
341
|
style,
|
|
229
342
|
display
|
|
@@ -320,6 +433,8 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
320
433
|
const result = [];
|
|
321
434
|
let done = false;
|
|
322
435
|
let separated = false;
|
|
436
|
+
let signDisplayed = true;
|
|
437
|
+
const negative = TABLE_2.some((row) => duration[row.valueField] < 0);
|
|
323
438
|
const internalSlots = getInternalSlots(df);
|
|
324
439
|
let dataLocale = internalSlots.dataLocale;
|
|
325
440
|
const dataLocaleData = DurationFormat.localeData[dataLocale];
|
|
@@ -328,7 +443,7 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
328
443
|
const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
|
|
329
444
|
for (let i = 0; i < TABLE_2.length && !done; i++) {
|
|
330
445
|
const row = TABLE_2[i];
|
|
331
|
-
let value = new BigDecimal(duration[row.valueField]);
|
|
446
|
+
let value = new BigDecimal(BigInt(duration[row.valueField]));
|
|
332
447
|
const style = internalSlots[row.styleSlot];
|
|
333
448
|
const display = internalSlots[row.displaySlot];
|
|
334
449
|
const { unit, numberFormatUnit } = row;
|
|
@@ -339,9 +454,9 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
339
454
|
else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
|
|
340
455
|
else nextStyle = internalSlots.nanoseconds;
|
|
341
456
|
if (nextStyle === "numeric" || nextStyle === "fractional") {
|
|
342
|
-
if (unit === "seconds") value = value.plus(new BigDecimal(duration.milliseconds).div(1e3)).plus(new BigDecimal(duration.microseconds).div(1e6)).plus(new BigDecimal(duration.nanoseconds).div(1e9));
|
|
343
|
-
else if (unit === "milliseconds") value = value.plus(new BigDecimal(duration.microseconds).div(1e3)).plus(new BigDecimal(duration.nanoseconds).div(1e6));
|
|
344
|
-
else value = value.plus(new BigDecimal(duration.nanoseconds).div(1e3));
|
|
457
|
+
if (unit === "seconds") value = value.plus(new BigDecimal(BigInt(duration.milliseconds)).div(1e3)).plus(new BigDecimal(BigInt(duration.microseconds)).div(1e6)).plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e9));
|
|
458
|
+
else if (unit === "milliseconds") value = value.plus(new BigDecimal(BigInt(duration.microseconds)).div(1e3)).plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e6));
|
|
459
|
+
else value = value.plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e3));
|
|
345
460
|
if (internalSlots.fractionalDigits === void 0) {
|
|
346
461
|
nfOpts.maximumFractionDigits = 9;
|
|
347
462
|
nfOpts.minimumFractionDigits = 0;
|
|
@@ -353,8 +468,14 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
353
468
|
done = true;
|
|
354
469
|
}
|
|
355
470
|
}
|
|
356
|
-
|
|
471
|
+
const minutesBetweenHoursAndSeconds = unit === "minutes" && separated && (internalSlots.secondsDisplay === "always" || duration.seconds !== 0 || duration.milliseconds !== 0 || duration.microseconds !== 0 || duration.nanoseconds !== 0);
|
|
472
|
+
if (!value.isZero() || display !== "auto" || minutesBetweenHoursAndSeconds) {
|
|
473
|
+
if (signDisplayed) {
|
|
474
|
+
if (value.isZero() && negative) value = new BigDecimal("-0");
|
|
475
|
+
signDisplayed = false;
|
|
476
|
+
} else nfOpts.signDisplay = "never";
|
|
357
477
|
nfOpts.numberingSystem = internalSlots.numberingSystem;
|
|
478
|
+
if (style === "numeric" || style === "2-digit") nfOpts.useGrouping = false;
|
|
358
479
|
if (style === "2-digit") nfOpts.minimumIntegerDigits = 2;
|
|
359
480
|
if (style !== "2-digit" && style !== "numeric" && style !== "fractional") {
|
|
360
481
|
nfOpts.style = "unit";
|
|
@@ -371,7 +492,7 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
371
492
|
value: separator
|
|
372
493
|
});
|
|
373
494
|
}
|
|
374
|
-
nf.formatToParts(value).forEach(({ type, value }) => {
|
|
495
|
+
nf.formatToParts(value.isZero() && value.isNegative() ? -0 : value).forEach(({ type, value }) => {
|
|
375
496
|
list.push({
|
|
376
497
|
type,
|
|
377
498
|
value,
|
|
@@ -401,12 +522,12 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
401
522
|
let resultLength = result.length;
|
|
402
523
|
let flattened = [];
|
|
403
524
|
for (const { type, value } of formatted) if (type === "element") {
|
|
404
|
-
invariant
|
|
525
|
+
invariant(resultIndex < resultLength, "Index out of bounds");
|
|
405
526
|
let parts = result[resultIndex];
|
|
406
527
|
for (const part of parts) flattened.push(part);
|
|
407
528
|
resultIndex++;
|
|
408
529
|
} else {
|
|
409
|
-
invariant
|
|
530
|
+
invariant(type === "literal", "Type must be literal");
|
|
410
531
|
flattened.push({
|
|
411
532
|
type: "literal",
|
|
412
533
|
value
|
|
@@ -443,93 +564,41 @@ function IsValidDurationRecord(record) {
|
|
|
443
564
|
const sign = DurationRecordSign(record);
|
|
444
565
|
for (const key of TABLE_1) {
|
|
445
566
|
const v = record[key];
|
|
446
|
-
|
|
567
|
+
if (!Number.isFinite(v)) return false;
|
|
447
568
|
if (v < 0 && sign > 0) return false;
|
|
448
569
|
if (v > 0 && sign < 0) return false;
|
|
449
570
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
return
|
|
459
|
-
}
|
|
460
|
-
function OrdinaryToPrimitive(O, hint) {
|
|
461
|
-
let methodNames;
|
|
462
|
-
if (hint === "string") methodNames = ["toString", "valueOf"];
|
|
463
|
-
else methodNames = ["valueOf", "toString"];
|
|
464
|
-
for (const name of methodNames) {
|
|
465
|
-
const method = O[name];
|
|
466
|
-
if (IsCallable(method)) {
|
|
467
|
-
let result = method.call(O);
|
|
468
|
-
if (typeof result !== "object") return result;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
throw new TypeError("Cannot convert object to primitive value");
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* https://tc39.es/ecma262/#sec-toprimitive
|
|
475
|
-
*/
|
|
476
|
-
function ToPrimitive(input, preferredType) {
|
|
477
|
-
if (typeof input === "object" && input != null) {
|
|
478
|
-
const exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : void 0;
|
|
479
|
-
let hint;
|
|
480
|
-
if (exoticToPrim !== void 0) {
|
|
481
|
-
if (preferredType === void 0) hint = "default";
|
|
482
|
-
else if (preferredType === "string") hint = "string";
|
|
483
|
-
else {
|
|
484
|
-
invariant$1(preferredType === "number", "preferredType must be \"string\" or \"number\"");
|
|
485
|
-
hint = "number";
|
|
486
|
-
}
|
|
487
|
-
let result = exoticToPrim.call(input, hint);
|
|
488
|
-
if (typeof result !== "object") return result;
|
|
489
|
-
throw new TypeError("Cannot convert exotic object to primitive.");
|
|
490
|
-
}
|
|
491
|
-
if (preferredType === void 0) preferredType = "number";
|
|
492
|
-
return OrdinaryToPrimitive(input, preferredType);
|
|
493
|
-
}
|
|
494
|
-
return input;
|
|
571
|
+
if ([
|
|
572
|
+
"years",
|
|
573
|
+
"months",
|
|
574
|
+
"weeks"
|
|
575
|
+
].some((unit) => Math.abs(record[unit]) >= 2 ** 32)) return false;
|
|
576
|
+
const billion = BigInt(1e9);
|
|
577
|
+
const normalizedNanoseconds = BigInt(record.days) * BigInt(86400) * billion + BigInt(record.hours) * BigInt(3600) * billion + BigInt(record.minutes) * BigInt(60) * billion + BigInt(record.seconds) * billion + BigInt(record.milliseconds) * BigInt(1e6) + BigInt(record.microseconds) * BigInt(1e3) + BigInt(record.nanoseconds);
|
|
578
|
+
const limit = BigInt(2 ** 53) * billion;
|
|
579
|
+
return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
|
|
495
580
|
}
|
|
496
581
|
//#endregion
|
|
497
582
|
//#region packages/ecma262-abstract/ToNumber.js
|
|
498
|
-
const ZERO = new Decimal(0);
|
|
499
|
-
function invariant(condition, message, Err = Error) {
|
|
500
|
-
if (!condition) throw new Err(message);
|
|
501
|
-
}
|
|
502
583
|
/**
|
|
584
|
+
* ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
|
|
503
585
|
* https://tc39.es/ecma262/#sec-tonumber
|
|
586
|
+
* https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L5183-L5191
|
|
504
587
|
*/
|
|
505
588
|
function ToNumber(arg) {
|
|
506
|
-
|
|
507
|
-
if (typeof arg === "bigint") return new Decimal(arg.toString());
|
|
508
|
-
invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
|
|
509
|
-
if (arg === void 0) return new Decimal(NaN);
|
|
510
|
-
if (arg === null || arg === 0) return ZERO;
|
|
511
|
-
if (arg === true) return new Decimal(1);
|
|
512
|
-
if (typeof arg === "string") try {
|
|
513
|
-
return new Decimal(arg);
|
|
514
|
-
} catch {
|
|
515
|
-
return new Decimal(NaN);
|
|
516
|
-
}
|
|
517
|
-
invariant(typeof arg === "object", "object expected", TypeError);
|
|
518
|
-
let primValue = ToPrimitive(arg, "number");
|
|
519
|
-
invariant(typeof primValue !== "object", "object expected", TypeError);
|
|
520
|
-
return ToNumber(primValue);
|
|
589
|
+
return new Decimal(+arg);
|
|
521
590
|
}
|
|
522
591
|
//#endregion
|
|
523
592
|
//#region packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
|
|
524
593
|
function ToIntegerIfIntegral(arg) {
|
|
525
594
|
const number = ToNumber(arg);
|
|
526
|
-
invariant
|
|
527
|
-
return number.toNumber();
|
|
595
|
+
invariant(number.isInteger(), "Duration field is not an integer", RangeError);
|
|
596
|
+
return number.isZero() ? 0 : number.toNumber();
|
|
528
597
|
}
|
|
529
598
|
//#endregion
|
|
530
599
|
//#region packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
|
|
531
600
|
function ToDurationRecord(input) {
|
|
532
|
-
if (typeof input !== "object") {
|
|
601
|
+
if ((typeof input !== "object" || input === null) && typeof input !== "function") {
|
|
533
602
|
if (typeof input === "string") throw new RangeError("Invalid duration format");
|
|
534
603
|
throw new TypeError("Invalid duration");
|
|
535
604
|
}
|
|
@@ -545,121 +614,62 @@ function ToDurationRecord(input) {
|
|
|
545
614
|
microseconds: 0,
|
|
546
615
|
nanoseconds: 0
|
|
547
616
|
};
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
617
|
+
let anyDefined = false;
|
|
618
|
+
for (const field of [
|
|
619
|
+
"days",
|
|
620
|
+
"hours",
|
|
621
|
+
"microseconds",
|
|
622
|
+
"milliseconds",
|
|
623
|
+
"minutes",
|
|
624
|
+
"months",
|
|
625
|
+
"nanoseconds",
|
|
626
|
+
"seconds",
|
|
627
|
+
"weeks",
|
|
628
|
+
"years"
|
|
629
|
+
]) {
|
|
630
|
+
const value = input[field];
|
|
631
|
+
if (value !== void 0) {
|
|
632
|
+
anyDefined = true;
|
|
633
|
+
result[field] = ToIntegerIfIntegral(value);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!anyDefined) throw new TypeError("Invalid duration format");
|
|
559
637
|
if (!IsValidDurationRecord(result)) throw new RangeError("Invalid duration format");
|
|
560
638
|
return result;
|
|
561
639
|
}
|
|
562
640
|
//#endregion
|
|
563
|
-
//#region
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
"
|
|
568
|
-
"
|
|
569
|
-
"
|
|
570
|
-
"
|
|
571
|
-
"
|
|
572
|
-
"
|
|
573
|
-
"
|
|
574
|
-
"
|
|
575
|
-
"
|
|
576
|
-
"
|
|
577
|
-
"cyrl",
|
|
578
|
-
"deva",
|
|
579
|
-
"diak",
|
|
580
|
-
"ethi",
|
|
581
|
-
"fullwide",
|
|
582
|
-
"gara",
|
|
583
|
-
"geor",
|
|
584
|
-
"gong",
|
|
585
|
-
"gonm",
|
|
586
|
-
"grek",
|
|
587
|
-
"greklow",
|
|
588
|
-
"gujr",
|
|
589
|
-
"gukh",
|
|
590
|
-
"guru",
|
|
591
|
-
"hanidays",
|
|
592
|
-
"hanidec",
|
|
593
|
-
"hans",
|
|
594
|
-
"hansfin",
|
|
595
|
-
"hant",
|
|
596
|
-
"hantfin",
|
|
597
|
-
"hebr",
|
|
598
|
-
"hmng",
|
|
599
|
-
"hmnp",
|
|
600
|
-
"java",
|
|
601
|
-
"jpan",
|
|
602
|
-
"jpanfin",
|
|
603
|
-
"jpanyear",
|
|
604
|
-
"kali",
|
|
605
|
-
"kawi",
|
|
606
|
-
"khmr",
|
|
607
|
-
"knda",
|
|
608
|
-
"krai",
|
|
609
|
-
"lana",
|
|
610
|
-
"lanatham",
|
|
611
|
-
"laoo",
|
|
612
|
-
"latn",
|
|
613
|
-
"lepc",
|
|
614
|
-
"limb",
|
|
615
|
-
"mathbold",
|
|
616
|
-
"mathdbl",
|
|
617
|
-
"mathmono",
|
|
618
|
-
"mathsanb",
|
|
619
|
-
"mathsans",
|
|
620
|
-
"mlym",
|
|
621
|
-
"modi",
|
|
622
|
-
"mong",
|
|
623
|
-
"mroo",
|
|
624
|
-
"mtei",
|
|
625
|
-
"mymr",
|
|
626
|
-
"mymrepka",
|
|
627
|
-
"mymrpao",
|
|
628
|
-
"mymrshan",
|
|
629
|
-
"mymrtlng",
|
|
630
|
-
"nagm",
|
|
631
|
-
"newa",
|
|
632
|
-
"nkoo",
|
|
633
|
-
"olck",
|
|
634
|
-
"onao",
|
|
635
|
-
"orya",
|
|
636
|
-
"osma",
|
|
637
|
-
"outlined",
|
|
638
|
-
"rohg",
|
|
639
|
-
"roman",
|
|
640
|
-
"romanlow",
|
|
641
|
-
"saur",
|
|
642
|
-
"segment",
|
|
643
|
-
"shrd",
|
|
644
|
-
"sind",
|
|
645
|
-
"sinh",
|
|
646
|
-
"sora",
|
|
647
|
-
"sund",
|
|
648
|
-
"sunu",
|
|
649
|
-
"takr",
|
|
650
|
-
"talu",
|
|
651
|
-
"taml",
|
|
652
|
-
"tamldec",
|
|
653
|
-
"telu",
|
|
654
|
-
"thai",
|
|
655
|
-
"tibt",
|
|
656
|
-
"tirh",
|
|
657
|
-
"tnsa",
|
|
658
|
-
"tols",
|
|
659
|
-
"vaii",
|
|
660
|
-
"wara",
|
|
661
|
-
"wcho"
|
|
641
|
+
//#region packages/intl-durationformat/abstract/ToTemporalDurationRecord.ts
|
|
642
|
+
const temporalDuration = globalThis.Temporal?.Duration;
|
|
643
|
+
const durationFrom = temporalDuration?.from;
|
|
644
|
+
const fields = [
|
|
645
|
+
"years",
|
|
646
|
+
"months",
|
|
647
|
+
"weeks",
|
|
648
|
+
"days",
|
|
649
|
+
"hours",
|
|
650
|
+
"minutes",
|
|
651
|
+
"seconds",
|
|
652
|
+
"milliseconds",
|
|
653
|
+
"microseconds",
|
|
654
|
+
"nanoseconds"
|
|
662
655
|
];
|
|
656
|
+
const getters = temporalDuration && fields.map((field) => Object.getOwnPropertyDescriptor(temporalDuration.prototype, field).get);
|
|
657
|
+
function ToTemporalDurationRecord(input) {
|
|
658
|
+
if (typeof input === "string" && durationFrom) input = durationFrom.call(temporalDuration, input);
|
|
659
|
+
if (getters && input !== null && (typeof input === "object" || typeof input === "function")) {
|
|
660
|
+
let years;
|
|
661
|
+
try {
|
|
662
|
+
years = getters[0].call(input);
|
|
663
|
+
} catch {
|
|
664
|
+
return ToDurationRecord(input);
|
|
665
|
+
}
|
|
666
|
+
const record = Object.create(null);
|
|
667
|
+
record.years = years;
|
|
668
|
+
for (let i = 1; i < fields.length; i++) record[fields[i]] = getters[i].call(input);
|
|
669
|
+
return record;
|
|
670
|
+
}
|
|
671
|
+
return ToDurationRecord(input);
|
|
672
|
+
}
|
|
663
673
|
//#endregion
|
|
664
674
|
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/time-separators.js
|
|
665
675
|
const TIME_SEPARATORS = {
|
|
@@ -1415,10 +1425,16 @@ const TIME_SEPARATORS = {
|
|
|
1415
1425
|
"twq": { "nu": ["latn"] },
|
|
1416
1426
|
"tyv": { "nu": ["latn"] },
|
|
1417
1427
|
"tzm": { "nu": ["latn"] },
|
|
1418
|
-
"ug": {
|
|
1428
|
+
"ug": {
|
|
1429
|
+
"nu": ["latn"],
|
|
1430
|
+
"separator": { "arabext": "٫" }
|
|
1431
|
+
},
|
|
1419
1432
|
"uk": { "nu": ["latn"] },
|
|
1420
1433
|
"und": { "nu": ["latn"] },
|
|
1421
|
-
"ur": {
|
|
1434
|
+
"ur": {
|
|
1435
|
+
"nu": ["latn"],
|
|
1436
|
+
"separator": { "arabext": "٫" }
|
|
1437
|
+
},
|
|
1422
1438
|
"ur-IN": {
|
|
1423
1439
|
"nu": ["arabext"],
|
|
1424
1440
|
"separator": { "arabext": "٫" }
|
|
@@ -1474,8 +1490,27 @@ const TIME_SEPARATORS = {
|
|
|
1474
1490
|
};
|
|
1475
1491
|
//#endregion
|
|
1476
1492
|
//#region packages/intl-durationformat/core.ts
|
|
1493
|
+
const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
|
|
1494
|
+
function supportedNumberingSystems() {
|
|
1495
|
+
const NumberFormat = Intl.NumberFormat;
|
|
1496
|
+
let systems = numberingSystemsByConstructor.get(NumberFormat);
|
|
1497
|
+
if (!systems) {
|
|
1498
|
+
systems = numberingSystemNames.filter((numberingSystem) => {
|
|
1499
|
+
const options = Object.create(null);
|
|
1500
|
+
options.numberingSystem = numberingSystem;
|
|
1501
|
+
try {
|
|
1502
|
+
return new NumberFormat("en", options).resolvedOptions().numberingSystem === numberingSystem;
|
|
1503
|
+
} catch {
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
if (systems.length) numberingSystemsByConstructor.set(NumberFormat, systems);
|
|
1508
|
+
}
|
|
1509
|
+
return systems;
|
|
1510
|
+
}
|
|
1477
1511
|
const RESOLVED_OPTIONS_KEYS = [
|
|
1478
1512
|
"locale",
|
|
1513
|
+
"numberingSystem",
|
|
1479
1514
|
"style",
|
|
1480
1515
|
"years",
|
|
1481
1516
|
"yearsDisplay",
|
|
@@ -1497,7 +1532,6 @@ const RESOLVED_OPTIONS_KEYS = [
|
|
|
1497
1532
|
"microsecondsDisplay",
|
|
1498
1533
|
"nanoseconds",
|
|
1499
1534
|
"nanosecondsDisplay",
|
|
1500
|
-
"numberingSystem",
|
|
1501
1535
|
"fractionalDigits"
|
|
1502
1536
|
];
|
|
1503
1537
|
const TABLE_3 = [
|
|
@@ -1633,7 +1667,7 @@ var DurationFormat = class DurationFormat {
|
|
|
1633
1667
|
const opts = options === void 0 ? Object.create(null) : ToObject(options);
|
|
1634
1668
|
const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
1635
1669
|
const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
|
|
1636
|
-
if (numberingSystem !== void 0 &&
|
|
1670
|
+
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeError(`Invalid numberingSystems: ${numberingSystem}`);
|
|
1637
1671
|
opt.nu = numberingSystem;
|
|
1638
1672
|
opt.localeMatcher = matcher;
|
|
1639
1673
|
const { localeData, availableLocales } = DurationFormat;
|
|
@@ -1668,16 +1702,17 @@ var DurationFormat = class DurationFormat {
|
|
|
1668
1702
|
for (const key of RESOLVED_OPTIONS_KEYS) {
|
|
1669
1703
|
let v = internalSlots[key];
|
|
1670
1704
|
if (key === "fractionalDigits") {
|
|
1671
|
-
if (v
|
|
1705
|
+
if (v === void 0) continue;
|
|
1706
|
+
v = Number(v);
|
|
1672
1707
|
} else if (v === "fractional") v = "numeric";
|
|
1673
|
-
else invariant
|
|
1708
|
+
else invariant(v !== void 0, `Missing internal slot ${key}`);
|
|
1674
1709
|
ro[key] = v;
|
|
1675
1710
|
}
|
|
1676
1711
|
return ro;
|
|
1677
1712
|
}
|
|
1678
1713
|
formatToParts(duration) {
|
|
1679
1714
|
if (getInternalSlots(this).initializedDurationFormat === void 0) throw new TypeError("Error uninitialized locale");
|
|
1680
|
-
const record =
|
|
1715
|
+
const record = ToTemporalDurationRecord(duration);
|
|
1681
1716
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1682
1717
|
const result = [];
|
|
1683
1718
|
for (const { type, unit, value } of parts) {
|
|
@@ -1692,7 +1727,7 @@ var DurationFormat = class DurationFormat {
|
|
|
1692
1727
|
}
|
|
1693
1728
|
format(duration) {
|
|
1694
1729
|
if (getInternalSlots(this).initializedDurationFormat === void 0) throw new TypeError("Error uninitialized locale");
|
|
1695
|
-
const record =
|
|
1730
|
+
const record = ToTemporalDurationRecord(duration);
|
|
1696
1731
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1697
1732
|
let result = "";
|
|
1698
1733
|
for (const { value } of parts) result += value;
|
|
@@ -1710,10 +1745,11 @@ var DurationFormat = class DurationFormat {
|
|
|
1710
1745
|
static {
|
|
1711
1746
|
this.localeData = Object.keys(TIME_SEPARATORS.localeData).reduce((all, locale) => {
|
|
1712
1747
|
DurationFormat.availableLocales.add(locale);
|
|
1713
|
-
const nu = [...TIME_SEPARATORS.localeData[locale].nu];
|
|
1714
|
-
if (!nu.includes("latn")) nu.push("latn");
|
|
1715
1748
|
all[locale] = {
|
|
1716
|
-
nu
|
|
1749
|
+
get nu() {
|
|
1750
|
+
const defaults = TIME_SEPARATORS.localeData[locale].nu;
|
|
1751
|
+
return [.../* @__PURE__ */ new Set([...defaults, ...supportedNumberingSystems()])];
|
|
1752
|
+
},
|
|
1717
1753
|
digitalFormat: {
|
|
1718
1754
|
default: TIME_SEPARATORS.default,
|
|
1719
1755
|
...TIME_SEPARATORS.localeData[locale].separator
|
|
@@ -1731,6 +1767,18 @@ var DurationFormat = class DurationFormat {
|
|
|
1731
1767
|
this.polyfilled = true;
|
|
1732
1768
|
}
|
|
1733
1769
|
};
|
|
1770
|
+
Object.defineProperty(DurationFormat, "length", {
|
|
1771
|
+
value: 0,
|
|
1772
|
+
configurable: true
|
|
1773
|
+
});
|
|
1774
|
+
Object.defineProperty(DurationFormat.supportedLocalesOf, "length", {
|
|
1775
|
+
value: 1,
|
|
1776
|
+
configurable: true
|
|
1777
|
+
});
|
|
1778
|
+
Object.defineProperty(DurationFormat.prototype, Symbol.toStringTag, {
|
|
1779
|
+
value: "Intl.DurationFormat",
|
|
1780
|
+
configurable: true
|
|
1781
|
+
});
|
|
1734
1782
|
//#endregion
|
|
1735
1783
|
//#region packages/intl-durationformat/should-polyfill.ts
|
|
1736
1784
|
function shouldPolyfill() {
|