@formatjs/intl-durationformat 0.12.4 → 0.13.1
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 +8 -2
- package/index.js +378 -135
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/polyfill-force.js +379 -135
- package/polyfill-force.js.map +1 -1
- package/polyfill.js +379 -135
- package/polyfill.js.map +1 -1
- package/should-polyfill.d.ts +1 -2
package/polyfill-force.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
|
|
2
|
-
import { BigDecimal
|
|
2
|
+
import { BigDecimal } from "@formatjs/bigdecimal";
|
|
3
3
|
// node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
|
|
4
4
|
const numberingSystemNames = [
|
|
5
5
|
"adlm",
|
|
@@ -101,40 +101,75 @@ const numberingSystemNames = [
|
|
|
101
101
|
"wcho"
|
|
102
102
|
];
|
|
103
103
|
// packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
|
|
104
|
+
const typeApply = Reflect.apply;
|
|
105
|
+
const typeExec = RegExp.prototype.exec;
|
|
106
|
+
const typePattern = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i;
|
|
104
107
|
/** Tests the Unicode locale identifier `type` grammar, not locale support. */
|
|
105
108
|
function IsUnicodeLocaleIdentifierType(value) {
|
|
106
|
-
return
|
|
109
|
+
return typeApply(typeExec, typePattern, [value]) !== null;
|
|
107
110
|
}
|
|
108
111
|
// packages/ecma262-abstract/OrdinaryHasInstance.js
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
const apply$3 = Reflect.apply;
|
|
113
|
+
const hasInstance = Function.prototype[Symbol.hasInstance];
|
|
114
|
+
/** ECMA-262 §7.3.21, via §20.2.3.6 step 2. */
|
|
115
|
+
function OrdinaryHasInstance(constructor, instance) {
|
|
116
|
+
return apply$3(hasInstance, constructor, [instance]);
|
|
111
117
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
// packages/ecma262-abstract/intrinsics.js
|
|
119
|
+
const floor = Math.floor;
|
|
120
|
+
const bigIntFrom = BigInt;
|
|
121
|
+
const objectFrom = Object;
|
|
122
|
+
const mathAbs = Math.abs;
|
|
123
|
+
const numberIsInteger = Number.isInteger;
|
|
124
|
+
const numberIsFinite = Number.isFinite;
|
|
125
|
+
Number.isSafeInteger;
|
|
126
|
+
const ErrorConstructor = Error;
|
|
127
|
+
const TypeErrorConstructor$1 = TypeError;
|
|
128
|
+
const RangeErrorConstructor = RangeError;
|
|
129
|
+
const arrayApply = Reflect.apply;
|
|
130
|
+
Array.prototype.every;
|
|
131
|
+
const some = Array.prototype.some;
|
|
132
|
+
function arraySome(values, predicate) {
|
|
133
|
+
return arrayApply(some, values, [predicate]);
|
|
134
|
+
}
|
|
135
|
+
Array.prototype.includes;
|
|
136
|
+
Array.prototype.indexOf;
|
|
137
|
+
const defineProperty$2 = Object.defineProperty;
|
|
138
|
+
function setDataProperty(target, key, value) {
|
|
139
|
+
defineProperty$2(target, key, {
|
|
140
|
+
__proto__: null,
|
|
141
|
+
value,
|
|
142
|
+
writable: true,
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true
|
|
145
|
+
});
|
|
122
146
|
}
|
|
123
147
|
// packages/ecma262-abstract/ToObject.js
|
|
124
148
|
/**
|
|
125
149
|
* https://tc39.es/ecma262/#sec-toobject
|
|
126
150
|
*/
|
|
127
151
|
function ToObject(arg) {
|
|
128
|
-
if (arg
|
|
129
|
-
return
|
|
152
|
+
if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
|
|
153
|
+
return objectFrom(arg);
|
|
130
154
|
}
|
|
131
155
|
// packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
156
|
+
let canonicalIntl = globalThis.Intl;
|
|
157
|
+
const canonicalDescriptor = Object.getOwnPropertyDescriptor;
|
|
158
|
+
const canonicalApply = Reflect.apply;
|
|
159
|
+
function ownCanonicalProvider() {
|
|
160
|
+
const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales");
|
|
161
|
+
return (descriptor && canonicalDescriptor(descriptor, "value"))?.value;
|
|
162
|
+
}
|
|
163
|
+
let canonicalProvider = ownCanonicalProvider();
|
|
132
164
|
/**
|
|
133
165
|
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
134
166
|
* @param locales
|
|
135
167
|
*/
|
|
136
168
|
function CanonicalizeLocaleList(locales) {
|
|
137
|
-
|
|
169
|
+
if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl;
|
|
170
|
+
const candidate = ownCanonicalProvider();
|
|
171
|
+
if (typeof candidate === "function") canonicalProvider = candidate;
|
|
172
|
+
return canonicalApply(canonicalProvider, canonicalIntl, [locales]);
|
|
138
173
|
}
|
|
139
174
|
// packages/ecma402-abstract/DefaultNumberOption.js
|
|
140
175
|
/**
|
|
@@ -149,8 +184,8 @@ function CanonicalizeLocaleList(locales) {
|
|
|
149
184
|
function DefaultNumberOption(inputVal, min, max, fallback) {
|
|
150
185
|
if (inputVal === void 0) return fallback;
|
|
151
186
|
const val = +inputVal;
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
187
|
+
if (val !== val || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`);
|
|
188
|
+
return floor(val);
|
|
154
189
|
}
|
|
155
190
|
// packages/ecma402-abstract/GetNumberOption.js
|
|
156
191
|
/**
|
|
@@ -165,15 +200,24 @@ function GetNumberOption(options, property, minimum, maximum, fallback) {
|
|
|
165
200
|
const val = options[property];
|
|
166
201
|
return DefaultNumberOption(val, minimum, maximum, fallback);
|
|
167
202
|
}
|
|
203
|
+
// packages/ecma262-abstract/IsObject.js
|
|
204
|
+
/** Includes browser host objects such as document.all. */
|
|
205
|
+
function IsObject(value) {
|
|
206
|
+
return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
|
|
207
|
+
}
|
|
168
208
|
// packages/ecma262-abstract/ToString.js
|
|
209
|
+
const StringConstructor = String;
|
|
210
|
+
const TypeErrorConstructor = TypeError;
|
|
169
211
|
/**
|
|
170
212
|
* https://tc39.es/ecma262/#sec-tostring
|
|
171
213
|
*/
|
|
172
214
|
function ToString(o) {
|
|
173
|
-
if (typeof o === "symbol") throw
|
|
174
|
-
return
|
|
215
|
+
if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
|
|
216
|
+
return StringConstructor(o);
|
|
175
217
|
}
|
|
176
218
|
// packages/ecma402-abstract/GetOption.js
|
|
219
|
+
const optionApply = Reflect.apply;
|
|
220
|
+
const optionJoin = Array.prototype.join;
|
|
177
221
|
/**
|
|
178
222
|
* https://tc39.es/ecma402/#sec-getoption
|
|
179
223
|
* @param opts
|
|
@@ -183,13 +227,13 @@ function ToString(o) {
|
|
|
183
227
|
* @param fallback
|
|
184
228
|
*/
|
|
185
229
|
function GetOption(opts, prop, type, values, fallback) {
|
|
186
|
-
if (opts
|
|
230
|
+
if (!IsObject(opts)) throw new TypeErrorConstructor$1("Options must be an object");
|
|
187
231
|
let value = opts[prop];
|
|
188
232
|
if (value !== void 0) {
|
|
189
|
-
if (type !== "boolean" && type !== "string") throw new
|
|
233
|
+
if (type !== "boolean" && type !== "string") throw new TypeErrorConstructor$1("invalid type");
|
|
190
234
|
if (type === "boolean") value = Boolean(value);
|
|
191
235
|
if (type === "string") value = ToString(value);
|
|
192
|
-
if (values !== void 0 && !values
|
|
236
|
+
if (values !== void 0 && !arraySome(values, (val) => val == value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`);
|
|
193
237
|
return value;
|
|
194
238
|
}
|
|
195
239
|
return fallback;
|
|
@@ -211,6 +255,13 @@ function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
|
211
255
|
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
212
256
|
}
|
|
213
257
|
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
258
|
+
const apply$2 = Reflect.apply;
|
|
259
|
+
const bind = Function.prototype.bind;
|
|
260
|
+
const slice = Array.prototype.slice;
|
|
261
|
+
const stringify = JSON.stringify;
|
|
262
|
+
const create = Object.create;
|
|
263
|
+
const defineProperty$1 = Object.defineProperty;
|
|
264
|
+
const setPrototypeOf = Object.setPrototypeOf;
|
|
214
265
|
function memoize(fn, options) {
|
|
215
266
|
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
216
267
|
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -226,23 +277,29 @@ function monadic(fn, cache, serializer, arg) {
|
|
|
226
277
|
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
|
227
278
|
let computedValue = cache.get(cacheKey);
|
|
228
279
|
if (typeof computedValue === "undefined") {
|
|
229
|
-
computedValue = fn
|
|
280
|
+
computedValue = apply$2(fn, this, [arg]);
|
|
230
281
|
cache.set(cacheKey, computedValue);
|
|
231
282
|
}
|
|
232
283
|
return computedValue;
|
|
233
284
|
}
|
|
234
285
|
function variadic(fn, cache, serializer) {
|
|
235
|
-
const args =
|
|
286
|
+
const args = apply$2(slice, arguments, [3]);
|
|
287
|
+
if (serializer === serializerDefault) setPrototypeOf(args, null);
|
|
236
288
|
const cacheKey = serializer(args);
|
|
237
289
|
let computedValue = cache.get(cacheKey);
|
|
238
290
|
if (typeof computedValue === "undefined") {
|
|
239
|
-
computedValue =
|
|
291
|
+
computedValue = apply$2(fn, this, args);
|
|
240
292
|
cache.set(cacheKey, computedValue);
|
|
241
293
|
}
|
|
242
294
|
return computedValue;
|
|
243
295
|
}
|
|
244
296
|
function assemble(fn, context, strategy, cache, serialize) {
|
|
245
|
-
return
|
|
297
|
+
return apply$2(bind, strategy, [
|
|
298
|
+
context,
|
|
299
|
+
fn,
|
|
300
|
+
cache,
|
|
301
|
+
serialize
|
|
302
|
+
]);
|
|
246
303
|
}
|
|
247
304
|
function strategyDefault(fn, options) {
|
|
248
305
|
const strategy = fn.length === 1 ? monadic : variadic;
|
|
@@ -255,11 +312,18 @@ function strategyMonadic(fn, options) {
|
|
|
255
312
|
return assemble(fn, this, monadic, options.cache.create(), options.serializer);
|
|
256
313
|
}
|
|
257
314
|
const serializerDefault = function() {
|
|
258
|
-
|
|
315
|
+
setPrototypeOf(arguments, null);
|
|
316
|
+
return stringify(arguments);
|
|
259
317
|
};
|
|
260
318
|
var ObjectWithoutPrototypeCache = class {
|
|
261
319
|
constructor() {
|
|
262
|
-
this
|
|
320
|
+
defineProperty$1(this, "cache", {
|
|
321
|
+
__proto__: null,
|
|
322
|
+
value: create(null),
|
|
323
|
+
writable: true,
|
|
324
|
+
enumerable: true,
|
|
325
|
+
configurable: true
|
|
326
|
+
});
|
|
263
327
|
}
|
|
264
328
|
get(key) {
|
|
265
329
|
return this.cache[key];
|
|
@@ -291,14 +355,93 @@ function ensureIntl() {
|
|
|
291
355
|
writable: true,
|
|
292
356
|
value: {}
|
|
293
357
|
});
|
|
358
|
+
if (providerIntl === void 0) providerIntl = Intl;
|
|
294
359
|
return Intl;
|
|
295
360
|
}
|
|
296
|
-
function invariant(condition, message, Err =
|
|
361
|
+
function invariant(condition, message, Err = ErrorConstructor) {
|
|
297
362
|
if (!condition) throw new Err(message);
|
|
298
363
|
}
|
|
299
|
-
|
|
364
|
+
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
300
365
|
memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
|
|
301
|
-
|
|
366
|
+
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
367
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
368
|
+
const formatterMemoizeOptions = {
|
|
369
|
+
__proto__: null,
|
|
370
|
+
strategy: strategies.variadic
|
|
371
|
+
};
|
|
372
|
+
let providerIntl = globalThis.Intl;
|
|
373
|
+
function ownIntlProvider(name) {
|
|
374
|
+
const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
|
|
375
|
+
return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
|
|
376
|
+
}
|
|
377
|
+
let numberFormatProvider = ownIntlProvider("NumberFormat");
|
|
378
|
+
let listFormatProvider = ownIntlProvider("ListFormat");
|
|
379
|
+
function getNumberFormatProvider() {
|
|
380
|
+
const candidate = ownIntlProvider("NumberFormat");
|
|
381
|
+
if (typeof candidate === "function") numberFormatProvider = candidate;
|
|
382
|
+
return numberFormatProvider;
|
|
383
|
+
}
|
|
384
|
+
function getListFormatProvider() {
|
|
385
|
+
const candidate = ownIntlProvider("ListFormat");
|
|
386
|
+
if (typeof candidate === "function") listFormatProvider = candidate;
|
|
387
|
+
return listFormatProvider;
|
|
388
|
+
}
|
|
389
|
+
const getFormatterPrototype = Object.getPrototypeOf;
|
|
390
|
+
const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
|
|
391
|
+
const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
|
|
392
|
+
const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
|
|
393
|
+
const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
|
|
394
|
+
const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
|
|
395
|
+
const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
|
|
396
|
+
function findFormatterPartsMethod(Constructor) {
|
|
397
|
+
const cached = getPartsMethod(Constructor);
|
|
398
|
+
if (cached) return cached;
|
|
399
|
+
let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
|
|
400
|
+
while (prototype != null) {
|
|
401
|
+
const inherited = getPartsOwner(prototype);
|
|
402
|
+
if (inherited) {
|
|
403
|
+
setPartsMethod(Constructor, inherited);
|
|
404
|
+
return inherited;
|
|
405
|
+
}
|
|
406
|
+
const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
|
|
407
|
+
const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
|
|
408
|
+
if (value && typeof value.value === "function") {
|
|
409
|
+
setPartsMethod(Constructor, value.value);
|
|
410
|
+
setPartsOwner(prototype, value.value);
|
|
411
|
+
return value.value;
|
|
412
|
+
}
|
|
413
|
+
prototype = getFormatterPrototype(prototype);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function getFormatterPartsMethod(Constructor) {
|
|
417
|
+
const method = findFormatterPartsMethod(Constructor);
|
|
418
|
+
if (!method) throw new TypeErrorConstructor$1("Missing supplied formatter parts method");
|
|
419
|
+
return method;
|
|
420
|
+
}
|
|
421
|
+
if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
|
|
422
|
+
if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
|
|
423
|
+
const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
424
|
+
const getNumberFormatMemoizer = numberFormatMemoizers.get.bind(numberFormatMemoizers);
|
|
425
|
+
const setNumberFormatMemoizer = numberFormatMemoizers.set.bind(numberFormatMemoizers);
|
|
426
|
+
const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
427
|
+
const getListFormatMemoizer = listFormatMemoizers.get.bind(listFormatMemoizers);
|
|
428
|
+
const setListFormatMemoizer = listFormatMemoizers.set.bind(listFormatMemoizers);
|
|
429
|
+
function createMemoizedNumberFormatForConstructor(Constructor) {
|
|
430
|
+
let factory = getNumberFormatMemoizer(Constructor);
|
|
431
|
+
if (!factory) {
|
|
432
|
+
factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
|
|
433
|
+
setNumberFormatMemoizer(Constructor, factory);
|
|
434
|
+
}
|
|
435
|
+
return factory;
|
|
436
|
+
}
|
|
437
|
+
function createMemoizedListFormatForConstructor(Constructor) {
|
|
438
|
+
let factory = getListFormatMemoizer(Constructor);
|
|
439
|
+
if (!factory) {
|
|
440
|
+
factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
|
|
441
|
+
setListFormatMemoizer(Constructor, factory);
|
|
442
|
+
}
|
|
443
|
+
return factory;
|
|
444
|
+
}
|
|
302
445
|
// packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
|
|
303
446
|
function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
|
|
304
447
|
let style = GetOption(options, unit, "string", stylesList, void 0);
|
|
@@ -320,9 +463,9 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
|
|
|
320
463
|
displayDefault = "auto";
|
|
321
464
|
}
|
|
322
465
|
const display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
|
|
323
|
-
if (display === "always" && style === "fractional") throw new
|
|
324
|
-
if (prevStyle === "fractional" && style !== "fractional") throw new
|
|
325
|
-
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new
|
|
466
|
+
if (display === "always" && style === "fractional") throw new RangeErrorConstructor("Fractional units cannot use always display");
|
|
467
|
+
if (prevStyle === "fractional" && style !== "fractional") throw new RangeErrorConstructor("Fractional units must be followed by fractional units");
|
|
468
|
+
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeErrorConstructor("Can't mix numeric and non-numeric styles");
|
|
326
469
|
if (twoDigitHours && unit === "hours") style = "2-digit";
|
|
327
470
|
if ((unit === "minutes" || unit === "seconds") && (prevStyle === "numeric" || prevStyle === "2-digit")) style = "2-digit";
|
|
328
471
|
return {
|
|
@@ -405,22 +548,42 @@ const TABLE_2 = [
|
|
|
405
548
|
];
|
|
406
549
|
// packages/intl-durationformat/get_internal_slots.ts
|
|
407
550
|
const internalSlotMap = /* @__PURE__ */ new WeakMap();
|
|
551
|
+
const getSlots = internalSlotMap.get.bind(internalSlotMap);
|
|
552
|
+
const setSlots = internalSlotMap.set.bind(internalSlotMap);
|
|
553
|
+
const createSlots = Object.create;
|
|
408
554
|
function getInternalSlots(x) {
|
|
409
|
-
let internalSlots =
|
|
555
|
+
let internalSlots = getSlots(x);
|
|
410
556
|
if (!internalSlots) {
|
|
411
|
-
internalSlots =
|
|
412
|
-
|
|
557
|
+
internalSlots = createSlots(null);
|
|
558
|
+
setSlots(x, internalSlots);
|
|
413
559
|
}
|
|
414
560
|
return internalSlots;
|
|
415
561
|
}
|
|
416
562
|
// packages/intl-durationformat/abstract/PartitionDurationFormatPattern.ts
|
|
563
|
+
const apply$1 = Reflect.apply;
|
|
564
|
+
const stringListIterator = Array.prototype[Symbol.iterator];
|
|
565
|
+
const stringListIteratorNext = Object.getPrototypeOf(apply$1(stringListIterator, [], [])).next;
|
|
566
|
+
const formatterProviders = /* @__PURE__ */ new WeakMap();
|
|
567
|
+
const getFormatterProviders = formatterProviders.get.bind(formatterProviders);
|
|
568
|
+
const setFormatterProviders = formatterProviders.set.bind(formatterProviders);
|
|
569
|
+
function initializeDurationFormatProviders(df) {
|
|
570
|
+
const NumberFormat = getNumberFormatProvider();
|
|
571
|
+
const ListFormat = getListFormatProvider();
|
|
572
|
+
setFormatterProviders(df, {
|
|
573
|
+
numberFormat: createMemoizedNumberFormatForConstructor(NumberFormat),
|
|
574
|
+
listFormat: createMemoizedListFormatForConstructor(ListFormat),
|
|
575
|
+
numberFormatToParts: getFormatterPartsMethod(NumberFormat),
|
|
576
|
+
listFormatToParts: getFormatterPartsMethod(ListFormat)
|
|
577
|
+
});
|
|
578
|
+
}
|
|
417
579
|
function PartitionDurationFormatPattern(df, duration) {
|
|
418
580
|
const result = [];
|
|
419
581
|
let done = false;
|
|
420
582
|
let separated = false;
|
|
421
583
|
let signDisplayed = true;
|
|
422
|
-
const negative = TABLE_2
|
|
584
|
+
const negative = arraySome(TABLE_2, (row) => duration[row.valueField] < 0);
|
|
423
585
|
const internalSlots = getInternalSlots(df);
|
|
586
|
+
const providers = getFormatterProviders(df);
|
|
424
587
|
let dataLocale = internalSlots.dataLocale;
|
|
425
588
|
const dataLocaleData = DurationFormat.localeData[dataLocale];
|
|
426
589
|
if (!dataLocaleData) throw new TypeError("Invalid locale");
|
|
@@ -428,20 +591,20 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
428
591
|
const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
|
|
429
592
|
for (let i = 0; i < TABLE_2.length && !done; i++) {
|
|
430
593
|
const row = TABLE_2[i];
|
|
431
|
-
let value = new BigDecimal(
|
|
594
|
+
let value = new BigDecimal(bigIntFrom(duration[row.valueField]));
|
|
432
595
|
const style = internalSlots[row.styleSlot];
|
|
433
596
|
const display = internalSlots[row.displaySlot];
|
|
434
597
|
const { unit, numberFormatUnit } = row;
|
|
435
|
-
const nfOpts =
|
|
598
|
+
const nfOpts = { __proto__: null };
|
|
436
599
|
if (unit === "seconds" || unit === "milliseconds" || unit === "microseconds") {
|
|
437
600
|
let nextStyle;
|
|
438
601
|
if (unit === "seconds") nextStyle = internalSlots.milliseconds;
|
|
439
602
|
else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
|
|
440
603
|
else nextStyle = internalSlots.nanoseconds;
|
|
441
604
|
if (nextStyle === "numeric" || nextStyle === "fractional") {
|
|
442
|
-
if (unit === "seconds") value = value.plus(new BigDecimal(
|
|
443
|
-
else if (unit === "milliseconds") value = value.plus(new BigDecimal(
|
|
444
|
-
else value = value.plus(new BigDecimal(
|
|
605
|
+
if (unit === "seconds") value = value.plus(new BigDecimal(bigIntFrom(duration.milliseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e6))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e9)));
|
|
606
|
+
else if (unit === "milliseconds") value = value.plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e6)));
|
|
607
|
+
else value = value.plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e3)));
|
|
445
608
|
if (internalSlots.fractionalDigits === void 0) {
|
|
446
609
|
nfOpts.maximumFractionDigits = 9;
|
|
447
610
|
nfOpts.minimumFractionDigits = 0;
|
|
@@ -467,56 +630,71 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
467
630
|
nfOpts.unit = numberFormatUnit;
|
|
468
631
|
nfOpts.unitDisplay = style;
|
|
469
632
|
}
|
|
470
|
-
const nf =
|
|
633
|
+
const nf = providers.numberFormat(internalSlots.locale, nfOpts);
|
|
471
634
|
let list;
|
|
472
635
|
if (!separated) list = [];
|
|
473
636
|
else {
|
|
474
637
|
list = result[result.length - 1];
|
|
475
|
-
list.
|
|
638
|
+
setDataProperty(list, `${list.length}`, {
|
|
476
639
|
type: "literal",
|
|
477
640
|
value: separator
|
|
478
641
|
});
|
|
479
642
|
}
|
|
480
|
-
nf
|
|
481
|
-
|
|
643
|
+
let parts = apply$1(providers.numberFormatToParts, nf, [value.isZero() && value.isNegative() ? -0 : value]);
|
|
644
|
+
for (let index = 0; index < parts.length; index++) {
|
|
645
|
+
const { type, value } = parts[index];
|
|
646
|
+
setDataProperty(list, `${list.length}`, {
|
|
482
647
|
type,
|
|
483
648
|
value,
|
|
484
649
|
unit: numberFormatUnit
|
|
485
650
|
});
|
|
486
|
-
}
|
|
651
|
+
}
|
|
487
652
|
if (!separated) {
|
|
488
653
|
if (style === "2-digit" || style === "numeric") separated = true;
|
|
489
|
-
result.
|
|
654
|
+
setDataProperty(result, `${result.length}`, list);
|
|
490
655
|
}
|
|
491
656
|
} else separated = false;
|
|
492
657
|
}
|
|
493
|
-
const lfOpts =
|
|
658
|
+
const lfOpts = { __proto__: null };
|
|
494
659
|
lfOpts.type = "unit";
|
|
495
660
|
let listStyle = internalSlots.style;
|
|
496
661
|
if (listStyle === "digital") listStyle = "short";
|
|
497
662
|
lfOpts.style = listStyle;
|
|
498
|
-
const lf =
|
|
663
|
+
const lf = providers.listFormat(internalSlots.locale, lfOpts);
|
|
499
664
|
const strings = [];
|
|
500
|
-
for (
|
|
665
|
+
for (let index = 0; index < result.length; index++) {
|
|
666
|
+
const parts = result[index];
|
|
501
667
|
let string = "";
|
|
502
|
-
for (
|
|
503
|
-
strings.
|
|
668
|
+
for (let partIndex = 0; partIndex < parts.length; partIndex++) string += parts[partIndex].value;
|
|
669
|
+
setDataProperty(strings, `${strings.length}`, string);
|
|
504
670
|
}
|
|
505
|
-
|
|
671
|
+
setDataProperty(strings, Symbol.iterator, () => {
|
|
672
|
+
const iterator = apply$1(stringListIterator, strings, []);
|
|
673
|
+
return {
|
|
674
|
+
__proto__: null,
|
|
675
|
+
next() {
|
|
676
|
+
return apply$1(stringListIteratorNext, iterator, []);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
});
|
|
680
|
+
let formatted = apply$1(providers.listFormatToParts, lf, [strings]);
|
|
506
681
|
let resultIndex = 0;
|
|
507
682
|
let resultLength = result.length;
|
|
508
|
-
|
|
509
|
-
for (
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
type
|
|
518
|
-
|
|
519
|
-
|
|
683
|
+
const flattened = [];
|
|
684
|
+
for (let index = 0; index < formatted.length; index++) {
|
|
685
|
+
const { type, value } = formatted[index];
|
|
686
|
+
if (type === "element") {
|
|
687
|
+
invariant(resultIndex < resultLength, "Index out of bounds");
|
|
688
|
+
let parts = result[resultIndex];
|
|
689
|
+
for (let index = 0; index < parts.length; index++) setDataProperty(flattened, `${flattened.length}`, parts[index]);
|
|
690
|
+
resultIndex++;
|
|
691
|
+
} else {
|
|
692
|
+
invariant(type === "literal", "Type must be literal");
|
|
693
|
+
setDataProperty(flattened, `${flattened.length}`, {
|
|
694
|
+
type: "literal",
|
|
695
|
+
value
|
|
696
|
+
});
|
|
697
|
+
}
|
|
520
698
|
}
|
|
521
699
|
return flattened;
|
|
522
700
|
}
|
|
@@ -535,7 +713,8 @@ const TABLE_1 = [
|
|
|
535
713
|
];
|
|
536
714
|
// packages/ecma402-abstract/DurationFormat/DurationRecordSign.js
|
|
537
715
|
function DurationRecordSign(record) {
|
|
538
|
-
for (
|
|
716
|
+
for (let index = 0; index < TABLE_1.length; index++) {
|
|
717
|
+
const key = TABLE_1[index];
|
|
539
718
|
if (record[key] < 0) return -1;
|
|
540
719
|
if (record[key] > 0) return 1;
|
|
541
720
|
}
|
|
@@ -544,42 +723,51 @@ function DurationRecordSign(record) {
|
|
|
544
723
|
// packages/ecma402-abstract/DurationFormat/IsValidDurationRecord.js
|
|
545
724
|
function IsValidDurationRecord(record) {
|
|
546
725
|
const sign = DurationRecordSign(record);
|
|
547
|
-
for (
|
|
548
|
-
const v = record[
|
|
549
|
-
if (!
|
|
726
|
+
for (let index = 0; index < TABLE_1.length; index++) {
|
|
727
|
+
const v = record[TABLE_1[index]];
|
|
728
|
+
if (!numberIsFinite(v)) return false;
|
|
550
729
|
if (v < 0 && sign > 0) return false;
|
|
551
730
|
if (v > 0 && sign < 0) return false;
|
|
552
731
|
}
|
|
553
|
-
if ([
|
|
732
|
+
if (arraySome([
|
|
554
733
|
"years",
|
|
555
734
|
"months",
|
|
556
735
|
"weeks"
|
|
557
|
-
]
|
|
558
|
-
const billion =
|
|
559
|
-
const normalizedNanoseconds =
|
|
560
|
-
const limit =
|
|
736
|
+
], (unit) => mathAbs(record[unit]) >= 2 ** 32)) return false;
|
|
737
|
+
const billion = bigIntFrom(1e9);
|
|
738
|
+
const normalizedNanoseconds = bigIntFrom(record.days) * bigIntFrom(86400) * billion + bigIntFrom(record.hours) * bigIntFrom(3600) * billion + bigIntFrom(record.minutes) * bigIntFrom(60) * billion + bigIntFrom(record.seconds) * billion + bigIntFrom(record.milliseconds) * bigIntFrom(1e6) + bigIntFrom(record.microseconds) * bigIntFrom(1e3) + bigIntFrom(record.nanoseconds);
|
|
739
|
+
const limit = bigIntFrom(2 ** 53) * billion;
|
|
561
740
|
return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
|
|
562
741
|
}
|
|
563
742
|
// packages/ecma262-abstract/ToNumber.js
|
|
564
|
-
/**
|
|
565
|
-
* ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
|
|
566
|
-
* https://tc39.es/ecma262/#sec-tonumber
|
|
567
|
-
* https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L5183-L5191
|
|
568
|
-
*/
|
|
743
|
+
/** ECMA-262 §7.1.4, via §13.5.4.1 step 2. */
|
|
569
744
|
function ToNumber(arg) {
|
|
570
|
-
return
|
|
745
|
+
return +arg;
|
|
571
746
|
}
|
|
572
747
|
// packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
|
|
748
|
+
/** ECMA-402 §13.5.2 steps 1–3. */
|
|
573
749
|
function ToIntegerIfIntegral(arg) {
|
|
574
750
|
const number = ToNumber(arg);
|
|
575
|
-
|
|
576
|
-
return number
|
|
751
|
+
if (!numberIsInteger(number)) throw new RangeErrorConstructor("Duration field is not an integer");
|
|
752
|
+
return number === 0 ? 0 : number;
|
|
577
753
|
}
|
|
578
754
|
// packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
|
|
755
|
+
const durationPropertyNames = [
|
|
756
|
+
"days",
|
|
757
|
+
"hours",
|
|
758
|
+
"microseconds",
|
|
759
|
+
"milliseconds",
|
|
760
|
+
"minutes",
|
|
761
|
+
"months",
|
|
762
|
+
"nanoseconds",
|
|
763
|
+
"seconds",
|
|
764
|
+
"weeks",
|
|
765
|
+
"years"
|
|
766
|
+
];
|
|
579
767
|
function ToDurationRecord(input) {
|
|
580
|
-
if ((
|
|
581
|
-
if (typeof input === "string") throw new
|
|
582
|
-
throw new
|
|
768
|
+
if (!IsObject(input)) {
|
|
769
|
+
if (typeof input === "string") throw new RangeErrorConstructor("Invalid duration format");
|
|
770
|
+
throw new TypeErrorConstructor$1("Invalid duration");
|
|
583
771
|
}
|
|
584
772
|
const result = {
|
|
585
773
|
years: 0,
|
|
@@ -594,31 +782,19 @@ function ToDurationRecord(input) {
|
|
|
594
782
|
nanoseconds: 0
|
|
595
783
|
};
|
|
596
784
|
let anyDefined = false;
|
|
597
|
-
for (
|
|
598
|
-
|
|
599
|
-
"hours",
|
|
600
|
-
"microseconds",
|
|
601
|
-
"milliseconds",
|
|
602
|
-
"minutes",
|
|
603
|
-
"months",
|
|
604
|
-
"nanoseconds",
|
|
605
|
-
"seconds",
|
|
606
|
-
"weeks",
|
|
607
|
-
"years"
|
|
608
|
-
]) {
|
|
785
|
+
for (let index = 0; index < durationPropertyNames.length; index++) {
|
|
786
|
+
const field = durationPropertyNames[index];
|
|
609
787
|
const value = input[field];
|
|
610
788
|
if (value !== void 0) {
|
|
611
789
|
anyDefined = true;
|
|
612
790
|
result[field] = ToIntegerIfIntegral(value);
|
|
613
791
|
}
|
|
614
792
|
}
|
|
615
|
-
if (!anyDefined) throw new
|
|
616
|
-
if (!IsValidDurationRecord(result)) throw new
|
|
793
|
+
if (!anyDefined) throw new TypeErrorConstructor$1("Invalid duration format");
|
|
794
|
+
if (!IsValidDurationRecord(result)) throw new RangeErrorConstructor("Invalid duration format");
|
|
617
795
|
return result;
|
|
618
796
|
}
|
|
619
|
-
// packages/
|
|
620
|
-
const temporalDuration = globalThis.Temporal?.Duration;
|
|
621
|
-
const durationFrom = temporalDuration?.from;
|
|
797
|
+
// packages/ecma402-abstract/DurationFormat/ToTemporalDurationRecord.js
|
|
622
798
|
const fields = [
|
|
623
799
|
"years",
|
|
624
800
|
"months",
|
|
@@ -631,19 +807,39 @@ const fields = [
|
|
|
631
807
|
"microseconds",
|
|
632
808
|
"nanoseconds"
|
|
633
809
|
];
|
|
634
|
-
const
|
|
810
|
+
const apply = Reflect.apply;
|
|
811
|
+
const readers = [];
|
|
812
|
+
function registerTemporalDurationNamespace(namespace) {
|
|
813
|
+
const constructor = namespace?.Duration;
|
|
814
|
+
if (!constructor || arraySome(readers, (reader) => reader.constructor === constructor)) return;
|
|
815
|
+
const from = constructor.from, prototype = constructor.prototype;
|
|
816
|
+
if (typeof from !== "function" || prototype === null || typeof prototype !== "object" && typeof prototype !== "function") return;
|
|
817
|
+
const getters = fields.map((field) => Object.getOwnPropertyDescriptor(prototype, field)?.get);
|
|
818
|
+
if (arraySome(getters, (getter) => typeof getter !== "function")) return;
|
|
819
|
+
readers.push({
|
|
820
|
+
constructor,
|
|
821
|
+
from,
|
|
822
|
+
getters
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
const temporal = globalThis.Temporal;
|
|
826
|
+
if (temporal) registerTemporalDurationNamespace(temporal);
|
|
635
827
|
function ToTemporalDurationRecord(input) {
|
|
636
|
-
if (typeof input === "string" &&
|
|
637
|
-
|
|
828
|
+
if (typeof input === "string" && readers.length) {
|
|
829
|
+
const reader = readers[readers.length - 1];
|
|
830
|
+
input = apply(reader.from, reader.constructor, [input]);
|
|
831
|
+
}
|
|
832
|
+
if (input !== null && (typeof input === "object" || typeof input === "function")) for (let index = 0; index < readers.length; index++) {
|
|
833
|
+
const reader = readers[index];
|
|
638
834
|
let years;
|
|
639
835
|
try {
|
|
640
|
-
years = getters[0]
|
|
836
|
+
years = apply(reader.getters[0], input, []);
|
|
641
837
|
} catch {
|
|
642
|
-
|
|
838
|
+
continue;
|
|
643
839
|
}
|
|
644
|
-
const record =
|
|
840
|
+
const record = { __proto__: null };
|
|
645
841
|
record.years = years;
|
|
646
|
-
for (let
|
|
842
|
+
for (let index = 1; index < fields.length; index++) record[fields[index]] = apply(reader.getters[index], input, []);
|
|
647
843
|
return record;
|
|
648
844
|
}
|
|
649
845
|
return ToDurationRecord(input);
|
|
@@ -1355,20 +1551,63 @@ const TIME_SEPARATORS = {
|
|
|
1355
1551
|
};
|
|
1356
1552
|
// packages/intl-durationformat/core.ts
|
|
1357
1553
|
const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
|
|
1554
|
+
const getNumberingSystems = numberingSystemsByConstructor.get.bind(numberingSystemsByConstructor);
|
|
1555
|
+
const setNumberingSystems = numberingSystemsByConstructor.set.bind(numberingSystemsByConstructor);
|
|
1556
|
+
const createObject = Object.create;
|
|
1557
|
+
const providerApply = Reflect.apply;
|
|
1558
|
+
const providerDescriptor = Object.getOwnPropertyDescriptor;
|
|
1559
|
+
const providerPrototype = Object.getPrototypeOf;
|
|
1560
|
+
const resolvedMethods = /* @__PURE__ */ new WeakMap();
|
|
1561
|
+
const getResolvedMethod = resolvedMethods.get.bind(resolvedMethods);
|
|
1562
|
+
const setResolvedMethod = resolvedMethods.set.bind(resolvedMethods);
|
|
1563
|
+
function numberFormatResolvedOptions(Constructor) {
|
|
1564
|
+
let prototype = Constructor.prototype;
|
|
1565
|
+
while (prototype !== null) {
|
|
1566
|
+
const cached = getResolvedMethod(prototype);
|
|
1567
|
+
if (cached) return cached;
|
|
1568
|
+
const descriptor = providerDescriptor(prototype, "resolvedOptions");
|
|
1569
|
+
const value = descriptor && providerDescriptor(descriptor, "value");
|
|
1570
|
+
if (typeof value?.value === "function") {
|
|
1571
|
+
const method = value.value;
|
|
1572
|
+
setResolvedMethod(prototype, method);
|
|
1573
|
+
return method;
|
|
1574
|
+
}
|
|
1575
|
+
prototype = providerPrototype(prototype);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
const initialNumberFormat = getNumberFormatProvider();
|
|
1579
|
+
if (typeof initialNumberFormat === "function") numberFormatResolvedOptions(initialNumberFormat);
|
|
1580
|
+
const NumberingSet = Set;
|
|
1581
|
+
const numberingAdd = Set.prototype.add;
|
|
1582
|
+
const numberingValues = Set.prototype.values;
|
|
1583
|
+
const numberingNext = providerPrototype(new NumberingSet().values()).next;
|
|
1584
|
+
function numberingUnion(first, second) {
|
|
1585
|
+
const unique = new NumberingSet();
|
|
1586
|
+
for (let index = 0; index < first.length; index++) providerApply(numberingAdd, unique, [first[index]]);
|
|
1587
|
+
for (let index = 0; index < second.length; index++) providerApply(numberingAdd, unique, [second[index]]);
|
|
1588
|
+
const iterator = providerApply(numberingValues, unique, []);
|
|
1589
|
+
const result = [];
|
|
1590
|
+
for (;;) {
|
|
1591
|
+
const next = providerApply(numberingNext, iterator, []);
|
|
1592
|
+
if (next.done) return result;
|
|
1593
|
+
setDataProperty(result, `${result.length}`, next.value);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1358
1596
|
function supportedNumberingSystems() {
|
|
1359
|
-
const NumberFormat =
|
|
1360
|
-
let systems =
|
|
1597
|
+
const NumberFormat = getNumberFormatProvider();
|
|
1598
|
+
let systems = getNumberingSystems(NumberFormat);
|
|
1361
1599
|
if (!systems) {
|
|
1362
|
-
systems =
|
|
1363
|
-
|
|
1600
|
+
systems = [];
|
|
1601
|
+
const resolvedOptions = numberFormatResolvedOptions(NumberFormat);
|
|
1602
|
+
for (let index = 0; index < numberingSystemNames.length; index++) {
|
|
1603
|
+
const numberingSystem = numberingSystemNames[index];
|
|
1604
|
+
const options = createObject(null);
|
|
1364
1605
|
options.numberingSystem = numberingSystem;
|
|
1365
1606
|
try {
|
|
1366
|
-
|
|
1367
|
-
} catch {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
});
|
|
1371
|
-
if (systems.length) numberingSystemsByConstructor.set(NumberFormat, systems);
|
|
1607
|
+
if (resolvedOptions && providerApply(resolvedOptions, new NumberFormat("en", options), []).numberingSystem === numberingSystem) setDataProperty(systems, `${systems.length}`, numberingSystem);
|
|
1608
|
+
} catch {}
|
|
1609
|
+
}
|
|
1610
|
+
if (systems.length) setNumberingSystems(NumberFormat, systems);
|
|
1372
1611
|
}
|
|
1373
1612
|
return systems;
|
|
1374
1613
|
}
|
|
@@ -1524,14 +1763,17 @@ const TABLE_3 = [
|
|
|
1524
1763
|
* Implements the Intl.DurationFormat API from the TC39 proposal
|
|
1525
1764
|
*/
|
|
1526
1765
|
var DurationFormat = class DurationFormat {
|
|
1766
|
+
static __addTemporalNamespace(namespace) {
|
|
1767
|
+
registerTemporalDurationNamespace(namespace);
|
|
1768
|
+
}
|
|
1527
1769
|
constructor(locales, options) {
|
|
1528
|
-
if (!
|
|
1770
|
+
if (!new.target) throw new TypeErrorConstructor$1("Intl.DurationFormat must be called with 'new'");
|
|
1529
1771
|
const requestedLocales = CanonicalizeLocaleList(locales);
|
|
1530
|
-
const opt =
|
|
1531
|
-
const opts = options === void 0 ?
|
|
1772
|
+
const opt = createObject(null);
|
|
1773
|
+
const opts = options === void 0 ? createObject(null) : ToObject(options);
|
|
1532
1774
|
const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
1533
1775
|
const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
|
|
1534
|
-
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw
|
|
1776
|
+
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeErrorConstructor(`Invalid numberingSystems: ${numberingSystem}`);
|
|
1535
1777
|
opt.nu = numberingSystem;
|
|
1536
1778
|
opt.localeMatcher = matcher;
|
|
1537
1779
|
const { localeData, availableLocales } = DurationFormat;
|
|
@@ -1550,14 +1792,15 @@ var DurationFormat = class DurationFormat {
|
|
|
1550
1792
|
internalSlots.style = style;
|
|
1551
1793
|
internalSlots.dataLocale = r.dataLocale;
|
|
1552
1794
|
let prevStyle = "";
|
|
1553
|
-
TABLE_3.
|
|
1554
|
-
const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } =
|
|
1795
|
+
for (let index = 0; index < TABLE_3.length; index++) {
|
|
1796
|
+
const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = TABLE_3[index];
|
|
1555
1797
|
const unitOptions = GetDurationUnitOptions(unit, opts, style, valueList, digitalBase, prevStyle);
|
|
1556
1798
|
internalSlots[styleSlot] = unitOptions.style;
|
|
1557
1799
|
internalSlots[displaySlot] = unitOptions.display;
|
|
1558
1800
|
if (unit === "hours" || unit === "minutes" || unit === "seconds" || unit === "milliseconds" || unit === "microseconds") prevStyle = unitOptions.style;
|
|
1559
|
-
}
|
|
1801
|
+
}
|
|
1560
1802
|
internalSlots.fractionalDigits = GetNumberOption(opts, "fractionalDigits", 0, 9, void 0);
|
|
1803
|
+
initializeDurationFormatProviders(this);
|
|
1561
1804
|
}
|
|
1562
1805
|
resolvedOptions() {
|
|
1563
1806
|
if (typeof this !== "object" || !OrdinaryHasInstance(DurationFormat, this)) throw TypeError("Method Intl.DurationFormat.prototype.resolvedOptions called on incompatible receiver");
|
|
@@ -1579,13 +1822,14 @@ var DurationFormat = class DurationFormat {
|
|
|
1579
1822
|
const record = ToTemporalDurationRecord(duration);
|
|
1580
1823
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1581
1824
|
const result = [];
|
|
1582
|
-
for (
|
|
1825
|
+
for (let index = 0; index < parts.length; index++) {
|
|
1826
|
+
const { type, unit, value } = parts[index];
|
|
1583
1827
|
const obj = {
|
|
1584
1828
|
type,
|
|
1585
1829
|
value
|
|
1586
1830
|
};
|
|
1587
|
-
if (unit) obj
|
|
1588
|
-
result.
|
|
1831
|
+
if (unit) setDataProperty(obj, "unit", unit);
|
|
1832
|
+
setDataProperty(result, `${result.length}`, obj);
|
|
1589
1833
|
}
|
|
1590
1834
|
return result;
|
|
1591
1835
|
}
|
|
@@ -1594,7 +1838,7 @@ var DurationFormat = class DurationFormat {
|
|
|
1594
1838
|
const record = ToTemporalDurationRecord(duration);
|
|
1595
1839
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1596
1840
|
let result = "";
|
|
1597
|
-
for (
|
|
1841
|
+
for (let index = 0; index < parts.length; index++) result += parts[index].value;
|
|
1598
1842
|
return result;
|
|
1599
1843
|
}
|
|
1600
1844
|
static supportedLocalesOf(locales, options) {
|
|
@@ -1612,7 +1856,7 @@ var DurationFormat = class DurationFormat {
|
|
|
1612
1856
|
all[locale] = {
|
|
1613
1857
|
get nu() {
|
|
1614
1858
|
const defaults = TIME_SEPARATORS.localeData[locale].nu;
|
|
1615
|
-
return
|
|
1859
|
+
return numberingUnion(defaults, supportedNumberingSystems());
|
|
1616
1860
|
},
|
|
1617
1861
|
digitalFormat: {
|
|
1618
1862
|
default: TIME_SEPARATORS.default,
|