@formatjs/intl-durationformat 0.10.9 → 0.10.10
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 +3 -3
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/polyfill-force.js +10 -5
- package/polyfill-force.js.map +1 -1
- package/polyfill.js +10 -5
- package/polyfill.js.map +1 -1
package/package.json
CHANGED
package/polyfill-force.js
CHANGED
|
@@ -187,7 +187,7 @@ memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic }
|
|
|
187
187
|
const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
188
188
|
//#endregion
|
|
189
189
|
//#region packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
|
|
190
|
-
function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle) {
|
|
190
|
+
function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
|
|
191
191
|
let style = GetOption(options, unit, "string", stylesList, void 0);
|
|
192
192
|
let displayDefault = "always";
|
|
193
193
|
if (style === void 0) if (baseStyle === "digital") {
|
|
@@ -199,10 +199,14 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
|
|
|
199
199
|
else style = baseStyle;
|
|
200
200
|
}
|
|
201
201
|
let display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
|
|
202
|
+
if (twoDigitHours && unit === "hours" && style === "numeric") style = "2-digit";
|
|
202
203
|
if (prevStyle === "numeric" || prevStyle === "2-digit") {
|
|
203
204
|
if (style !== "numeric" && style !== "2-digit") throw new RangeError("Can't mix numeric and non-numeric styles");
|
|
204
205
|
else if (unit === "minutes" || unit === "seconds") style = "2-digit";
|
|
205
|
-
if (style === "numeric" &&
|
|
206
|
+
if (style === "numeric" && (unit === "milliseconds" || unit === "microseconds" || unit === "nanoseconds")) {
|
|
207
|
+
if (display === "always") throw new RangeError("Can't display milliseconds, microseconds, or nanoseconds in numeric format");
|
|
208
|
+
style = "fractional";
|
|
209
|
+
}
|
|
206
210
|
}
|
|
207
211
|
return {
|
|
208
212
|
style,
|
|
@@ -318,7 +322,7 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
318
322
|
if (unit === "seconds") nextStyle = internalSlots.milliseconds;
|
|
319
323
|
else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
|
|
320
324
|
else nextStyle = internalSlots.nanoseconds;
|
|
321
|
-
if (nextStyle === "numeric") {
|
|
325
|
+
if (nextStyle === "numeric" || nextStyle === "fractional") {
|
|
322
326
|
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));
|
|
323
327
|
else if (unit === "milliseconds") value = value.plus(new BigDecimal(duration.microseconds).div(1e3)).plus(new BigDecimal(duration.nanoseconds).div(1e6));
|
|
324
328
|
else value = value.plus(new BigDecimal(duration.nanoseconds).div(1e3));
|
|
@@ -336,7 +340,7 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
336
340
|
if (!value.isZero() || display !== "auto") {
|
|
337
341
|
nfOpts.numberingSystem = internalSlots.numberingSystem;
|
|
338
342
|
if (style === "2-digit") nfOpts.minimumIntegerDigits = 2;
|
|
339
|
-
if (style !== "2-digit" && style !== "numeric") {
|
|
343
|
+
if (style !== "2-digit" && style !== "numeric" && style !== "fractional") {
|
|
340
344
|
nfOpts.style = "unit";
|
|
341
345
|
nfOpts.unit = numberFormatUnit;
|
|
342
346
|
nfOpts.unitDisplay = style;
|
|
@@ -1649,7 +1653,8 @@ var DurationFormat = class DurationFormat {
|
|
|
1649
1653
|
let v = internalSlots[key];
|
|
1650
1654
|
if (key === "fractionalDigits") {
|
|
1651
1655
|
if (v !== void 0) v = Number(v);
|
|
1652
|
-
} else
|
|
1656
|
+
} else if (v === "fractional") v = "numeric";
|
|
1657
|
+
else invariant$2(v !== void 0, `Missing internal slot ${key}`);
|
|
1653
1658
|
ro[key] = v;
|
|
1654
1659
|
}
|
|
1655
1660
|
return ro;
|