@formatjs/intl-datetimeformat 4.5.0 → 4.5.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/package.json +3 -3
- package/polyfill.iife.js +30 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-datetimeformat",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"description": "Intl.DateTimeFormat polyfill",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/formatjs/formatjs#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@formatjs/ecma402-abstract": "1.11.
|
|
26
|
-
"@formatjs/intl-localematcher": "0.2.
|
|
25
|
+
"@formatjs/ecma402-abstract": "1.11.2",
|
|
26
|
+
"@formatjs/intl-localematcher": "0.2.23",
|
|
27
27
|
"tslib": "^2.1.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/polyfill.iife.js
CHANGED
|
@@ -30,6 +30,19 @@
|
|
|
30
30
|
}, enumerable: true } : { value: module, enumerable: true })), module);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/CanonicalizeLocaleList.js
|
|
34
|
+
var require_CanonicalizeLocaleList = __commonJS({
|
|
35
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/CanonicalizeLocaleList.js": function(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.CanonicalizeLocaleList = void 0;
|
|
39
|
+
function CanonicalizeLocaleList2(locales) {
|
|
40
|
+
return Intl.getCanonicalLocales(locales);
|
|
41
|
+
}
|
|
42
|
+
exports.CanonicalizeLocaleList = CanonicalizeLocaleList2;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
33
46
|
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js
|
|
34
47
|
var require_utils = __commonJS({
|
|
35
48
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
|
|
@@ -114,14 +127,16 @@
|
|
|
114
127
|
var utils_1 = require_utils();
|
|
115
128
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
116
129
|
var minimizedAvailableLocaleMap = {};
|
|
117
|
-
availableLocales.forEach(function(l2) {
|
|
118
|
-
return minimizedAvailableLocaleMap[l2] = l2;
|
|
119
|
-
});
|
|
120
130
|
var minimizedAvailableLocales = /* @__PURE__ */ new Set();
|
|
121
131
|
availableLocales.forEach(function(locale2) {
|
|
122
132
|
var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
|
|
133
|
+
var canonicalizedLocale = Intl.getCanonicalLocales(locale2)[0] || locale2;
|
|
123
134
|
minimizedAvailableLocaleMap[minimizedLocale] = locale2;
|
|
135
|
+
minimizedAvailableLocaleMap[locale2] = locale2;
|
|
136
|
+
minimizedAvailableLocaleMap[canonicalizedLocale] = locale2;
|
|
124
137
|
minimizedAvailableLocales.add(minimizedLocale);
|
|
138
|
+
minimizedAvailableLocales.add(locale2);
|
|
139
|
+
minimizedAvailableLocales.add(canonicalizedLocale);
|
|
125
140
|
});
|
|
126
141
|
var foundLocale;
|
|
127
142
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -147,8 +162,11 @@
|
|
|
147
162
|
}
|
|
148
163
|
foundLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
149
164
|
}
|
|
165
|
+
if (!foundLocale) {
|
|
166
|
+
return { locale: getDefaultLocale() };
|
|
167
|
+
}
|
|
150
168
|
return {
|
|
151
|
-
locale:
|
|
169
|
+
locale: minimizedAvailableLocaleMap[foundLocale] || foundLocale
|
|
152
170
|
};
|
|
153
171
|
}
|
|
154
172
|
exports.BestFitMatcher = BestFitMatcher;
|
|
@@ -309,13 +327,14 @@
|
|
|
309
327
|
"use strict";
|
|
310
328
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
311
329
|
exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
|
|
330
|
+
var CanonicalizeLocaleList_1 = require_CanonicalizeLocaleList();
|
|
312
331
|
var ResolveLocale_1 = require_ResolveLocale();
|
|
313
332
|
function match2(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
314
333
|
var locales = availableLocales.reduce(function(all, l) {
|
|
315
334
|
all.add(l);
|
|
316
335
|
return all;
|
|
317
336
|
}, /* @__PURE__ */ new Set());
|
|
318
|
-
return (0, ResolveLocale_1.ResolveLocale)(locales, requestedLocales, {
|
|
337
|
+
return (0, ResolveLocale_1.ResolveLocale)(locales, (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(requestedLocales), {
|
|
319
338
|
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
320
339
|
}, [], {}, function() {
|
|
321
340
|
return defaultLocale;
|
|
@@ -770,7 +789,7 @@
|
|
|
770
789
|
function getInternalSlots(x) {
|
|
771
790
|
var internalSlots = internalSlotMap.get(x);
|
|
772
791
|
if (!internalSlots) {
|
|
773
|
-
internalSlots = Object.create(null);
|
|
792
|
+
internalSlots = /* @__PURE__ */ Object.create(null);
|
|
774
793
|
internalSlotMap.set(x, internalSlots);
|
|
775
794
|
}
|
|
776
795
|
return internalSlots;
|
|
@@ -1022,17 +1041,17 @@
|
|
|
1022
1041
|
var dataLocale = internalSlots.dataLocale;
|
|
1023
1042
|
var dataLocaleData = localeData[dataLocale];
|
|
1024
1043
|
var locale = internalSlots.locale;
|
|
1025
|
-
var nfOptions = Object.create(null);
|
|
1044
|
+
var nfOptions = /* @__PURE__ */ Object.create(null);
|
|
1026
1045
|
nfOptions.useGrouping = false;
|
|
1027
1046
|
var nf = new Intl.NumberFormat(locale, nfOptions);
|
|
1028
|
-
var nf2Options = Object.create(null);
|
|
1047
|
+
var nf2Options = /* @__PURE__ */ Object.create(null);
|
|
1029
1048
|
nf2Options.minimumIntegerDigits = 2;
|
|
1030
1049
|
nf2Options.useGrouping = false;
|
|
1031
1050
|
var nf2 = new Intl.NumberFormat(locale, nf2Options);
|
|
1032
1051
|
var fractionalSecondDigits = internalSlots.fractionalSecondDigits;
|
|
1033
1052
|
var nf3;
|
|
1034
1053
|
if (fractionalSecondDigits !== void 0) {
|
|
1035
|
-
var nf3Options = Object.create(null);
|
|
1054
|
+
var nf3Options = /* @__PURE__ */ Object.create(null);
|
|
1036
1055
|
nf3Options.minimumIntegerDigits = fractionalSecondDigits;
|
|
1037
1056
|
nf3Options.useGrouping = false;
|
|
1038
1057
|
nf3 = new Intl.NumberFormat(locale, nf3Options);
|
|
@@ -1674,7 +1693,7 @@
|
|
|
1674
1693
|
var getInternalSlots2 = _a.getInternalSlots, availableLocales = _a.availableLocales, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getDefaultTimeZone = _a.getDefaultTimeZone, relevantExtensionKeys = _a.relevantExtensionKeys, tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
|
|
1675
1694
|
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
1676
1695
|
var options = ToDateTimeOptions(opts, "any", "date");
|
|
1677
|
-
var opt = Object.create(null);
|
|
1696
|
+
var opt = /* @__PURE__ */ Object.create(null);
|
|
1678
1697
|
var matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
1679
1698
|
opt.localeMatcher = matcher;
|
|
1680
1699
|
var calendar = GetOption(options, "calendar", "string", void 0, void 0);
|
|
@@ -1713,7 +1732,7 @@
|
|
|
1713
1732
|
timeZone = getDefaultTimeZone();
|
|
1714
1733
|
}
|
|
1715
1734
|
internalSlots.timeZone = timeZone;
|
|
1716
|
-
opt = Object.create(null);
|
|
1735
|
+
opt = /* @__PURE__ */ Object.create(null);
|
|
1717
1736
|
opt.weekday = GetOption(options, "weekday", "string", ["narrow", "short", "long"], void 0);
|
|
1718
1737
|
opt.era = GetOption(options, "era", "string", ["narrow", "short", "long"], void 0);
|
|
1719
1738
|
opt.year = GetOption(options, "year", "string", ["2-digit", "numeric"], void 0);
|