@formatjs/intl-datetimeformat 4.2.3 → 4.3.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 +1 -1
- package/lib/should-polyfill.d.ts +1 -1
- package/lib/should-polyfill.d.ts.map +1 -1
- package/lib/should-polyfill.js +7 -2
- package/lib/src/abstract/FormatDateTimePattern.js +1 -1
- package/lib/src/abstract/InitializeDateTimeFormat.js +3 -3
- package/lib/src/abstract/skeleton.js +1 -1
- package/lib/src/core.js +1 -1
- package/lib/src/packer.js +2 -2
- package/lib/supported-locales.d.ts +2 -0
- package/lib/supported-locales.d.ts.map +1 -0
- package/lib/supported-locales.js +2 -0
- package/package.json +3 -3
- package/polyfill-force.js +7 -7
- package/polyfill.iife.js +82 -71
- package/polyfill.js +8 -8
- package/should-polyfill.d.ts +1 -1
- package/should-polyfill.d.ts.map +1 -1
- package/should-polyfill.js +7 -2
- package/src/abstract/BasicFormatMatcher.js +2 -2
- package/src/abstract/BestFitFormatMatcher.js +3 -3
- package/src/abstract/DateTimeStyleFormat.js +3 -3
- package/src/abstract/FormatDateTime.js +1 -1
- package/src/abstract/FormatDateTimePattern.js +3 -3
- package/src/abstract/FormatDateTimeRange.js +1 -1
- package/src/abstract/FormatDateTimeRangeToParts.js +1 -1
- package/src/abstract/FormatDateTimeToParts.js +2 -2
- package/src/abstract/InitializeDateTimeFormat.js +30 -30
- package/src/abstract/PartitionDateTimePattern.js +2 -2
- package/src/abstract/PartitionDateTimeRangePattern.js +9 -9
- package/src/abstract/ToDateTimeOptions.js +1 -1
- package/src/abstract/ToLocalTime.js +10 -10
- package/src/abstract/skeleton.js +3 -3
- package/src/core.js +43 -43
- package/src/packer.js +3 -3
- package/src/to_locale_string.js +2 -2
- package/supported-locales.d.ts +2 -0
- package/supported-locales.d.ts.map +1 -0
- package/supported-locales.js +5 -0
- package/test262-main.js +1 -1
package/index.js
CHANGED
package/lib/should-polyfill.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function shouldPolyfill(locale?: string |
|
|
1
|
+
export declare function shouldPolyfill(locale?: string): string | undefined;
|
|
2
2
|
//# sourceMappingURL=should-polyfill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-datetimeformat/should-polyfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-datetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAyDA,wBAAgB,cAAc,CAAC,MAAM,SAAO,GAAG,MAAM,GAAG,SAAS,CAYhE"}
|
package/lib/should-polyfill.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { match } from '@formatjs/intl-localematcher';
|
|
2
|
+
import { supportedLocales } from './supported-locales';
|
|
1
3
|
function supportsDateStyle() {
|
|
2
4
|
try {
|
|
3
5
|
return !!new Intl.DateTimeFormat(undefined, {
|
|
@@ -46,11 +48,14 @@ function supportedLocalesOf(locale) {
|
|
|
46
48
|
return (Intl.DateTimeFormat.supportedLocalesOf(locales).length === locales.length);
|
|
47
49
|
}
|
|
48
50
|
export function shouldPolyfill(locale) {
|
|
49
|
-
|
|
51
|
+
if (locale === void 0) { locale = 'en'; }
|
|
52
|
+
if (!('DateTimeFormat' in Intl) ||
|
|
50
53
|
!('formatToParts' in Intl.DateTimeFormat.prototype) ||
|
|
51
54
|
!('formatRange' in Intl.DateTimeFormat.prototype) ||
|
|
52
55
|
hasChromeLt71Bug() ||
|
|
53
56
|
hasUnthrownDateTimeStyleBug() ||
|
|
54
57
|
!supportsDateStyle() ||
|
|
55
|
-
!supportedLocalesOf(locale))
|
|
58
|
+
!supportedLocalesOf(locale)) {
|
|
59
|
+
return locale ? match([locale], supportedLocales, 'en') : undefined;
|
|
60
|
+
}
|
|
56
61
|
}
|
|
@@ -107,11 +107,11 @@ export function InitializeDateTimeFormat(dtf, locales, opts, _a) {
|
|
|
107
107
|
// @ts-expect-error
|
|
108
108
|
undefined);
|
|
109
109
|
var dataLocaleData = localeData[dataLocale];
|
|
110
|
-
invariant(!!dataLocaleData, "Missing locale data for "
|
|
110
|
+
invariant(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
|
|
111
111
|
var formats = dataLocaleData.formats[calendar];
|
|
112
112
|
// UNSPECCED: IMPLEMENTATION DETAILS
|
|
113
113
|
if (!formats) {
|
|
114
|
-
throw new RangeError("Calendar \""
|
|
114
|
+
throw new RangeError("Calendar \"".concat(calendar, "\" is not supported. Try setting \"calendar\" to 1 of the following: ").concat(Object.keys(dataLocaleData.formats).join(', ')));
|
|
115
115
|
}
|
|
116
116
|
var formatMatcher = GetOption(options, 'formatMatcher', 'string', ['basic', 'best fit'], 'best fit');
|
|
117
117
|
var dateStyle = GetOption(options, 'dateStyle', 'string', ['full', 'long', 'medium', 'short'], undefined);
|
|
@@ -138,7 +138,7 @@ export function InitializeDateTimeFormat(dtf, locales, opts, _a) {
|
|
|
138
138
|
var prop = DATE_TIME_PROPS_1[_i];
|
|
139
139
|
var p = opt[prop];
|
|
140
140
|
if (p !== undefined) {
|
|
141
|
-
throw new TypeError("Intl.DateTimeFormat can't set option "
|
|
141
|
+
throw new TypeError("Intl.DateTimeFormat can't set option ".concat(prop, " when ").concat(dateStyle ? 'dateStyle' : 'timeStyle', " is used"));
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
bestFormat = DateTimeStyleFormat(dateStyle, timeStyle, dataLocaleData);
|
|
@@ -172,7 +172,7 @@ export function processDateTimePattern(pattern, result) {
|
|
|
172
172
|
// Apostrophe-escaped
|
|
173
173
|
.replace(/'(.*?)'/g, function (_, literal) {
|
|
174
174
|
literals.push(literal);
|
|
175
|
-
return "$$"
|
|
175
|
+
return "$$".concat(literals.length - 1, "$$");
|
|
176
176
|
})
|
|
177
177
|
.replace(DATE_TIME_REGEX, function (m) { return matchSkeletonPattern(m, result || {}); });
|
|
178
178
|
//Restore literals
|
package/lib/src/core.js
CHANGED
|
@@ -111,7 +111,7 @@ export var DateTimeFormat = function (locales, options) {
|
|
|
111
111
|
var internalSlots = getInternalSlots(this);
|
|
112
112
|
var dataLocale = internalSlots.dataLocale;
|
|
113
113
|
var dataLocaleData = DateTimeFormat.localeData[dataLocale];
|
|
114
|
-
invariant(dataLocaleData !== undefined, "Cannot load locale-dependent data for "
|
|
114
|
+
invariant(dataLocaleData !== undefined, "Cannot load locale-dependent data for ".concat(dataLocale, "."));
|
|
115
115
|
/** IMPL END */
|
|
116
116
|
};
|
|
117
117
|
// Static properties
|
package/lib/src/packer.js
CHANGED
|
@@ -8,8 +8,8 @@ export function pack(data) {
|
|
|
8
8
|
zone
|
|
9
9
|
], data.zones[zone].map(function (_a) {
|
|
10
10
|
var ts = _a[0], others = _a.slice(1);
|
|
11
|
-
return __spreadArray([ts === '' ? '' : ts.toString(36)], others).join(',');
|
|
12
|
-
})).join('|');
|
|
11
|
+
return __spreadArray([ts === '' ? '' : ts.toString(36)], others, true).join(',');
|
|
12
|
+
}), true).join('|');
|
|
13
13
|
}),
|
|
14
14
|
abbrvs: data.abbrvs.join('|'),
|
|
15
15
|
offsets: data.offsets.map(function (o) { return o.toString(36); }).join('|'),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-locales.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-datetimeformat/supported-locales.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,EAAE,MAAM,EAA+nI,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated from supported-locales-gen.ts
|
|
2
|
+
export var supportedLocales = ["af-NA", "af", "agq", "ak", "am", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "ar", "as", "asa", "ast", "az-Cyrl", "az-Latn", "az", "bas", "be", "bem", "bez", "bg", "bm", "bn-IN", "bn", "bo-IN", "bo", "br", "brx", "bs-Cyrl", "bs-Latn", "bs", "ca-AD", "ca-ES-VALENCIA", "ca-FR", "ca-IT", "ca", "ccp-IN", "ccp", "ce", "ceb", "cgg", "chr", "ckb-IR", "ckb", "cs", "cy", "da-GL", "da", "dav", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "de", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee-TG", "ee", "el-CY", "el", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-US-POSIX", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "en", "eo", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "es", "et", "eu", "ewo", "fa-AF", "fa", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Adlm", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "ff-Latn", "ff", "fi", "fil", "fo-DK", "fo", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fr", "fur", "fy", "ga-GB", "ga", "gd", "gl", "gsw-FR", "gsw-LI", "gsw", "gu", "guz", "gv", "ha-GH", "ha-NE", "ha", "haw", "he", "hi", "hr-BA", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it-CH", "it-SM", "it-VA", "it", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko-KP", "ko", "kok", "ks-Arab", "ks", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln-AO", "ln-CF", "ln-CG", "ln", "lo", "lrc-IQ", "lrc", "lt", "lu", "luo", "luy", "lv", "mai", "mas-TZ", "mas", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni-Beng", "mni", "mr", "ms-BN", "ms-ID", "ms-SG", "ms", "mt", "mua", "my", "mzn", "naq", "nb-SJ", "nb", "nd", "nds-NL", "nds", "ne-IN", "ne", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nl", "nmg", "nn", "nnh", "no", "nus", "nyn", "om-KE", "om", "or", "os-RU", "os", "pa-Arab", "pa-Guru", "pa", "pcm", "pl", "ps-PK", "ps", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "pt", "qu-BO", "qu-EC", "qu", "rm", "rn", "ro-MD", "ro", "rof", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "ru", "rw", "rwk", "sa", "sah", "saq", "sat-Olck", "sat", "sbp", "sd-Arab", "sd-Deva", "sd", "se-FI", "se-SE", "se", "seh", "ses", "sg", "shi-Latn", "shi-Tfng", "shi", "si", "sk", "sl", "smn", "sn", "so-DJ", "so-ET", "so-KE", "so", "sq-MK", "sq-XK", "sq", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Cyrl", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "sr-Latn", "sr", "su-Latn", "su", "sv-AX", "sv-FI", "sv", "sw-CD", "sw-KE", "sw-UG", "sw", "ta-LK", "ta-MY", "ta-SG", "ta", "te", "teo-KE", "teo", "tg", "th", "ti-ER", "ti", "tk", "to", "tr-CY", "tr", "tt", "twq", "tzm", "ug", "uk", "ur-IN", "ur", "uz-Arab", "uz-Cyrl", "uz-Latn", "uz", "vai-Latn", "vai-Vaii", "vai", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo-BJ", "yo", "yue-Hans", "yue-Hant", "yue", "zgh", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hans", "zh-Hant-HK", "zh-Hant-MO", "zh-Hant", "zh", "zu"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-datetimeformat",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
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.
|
|
26
|
-
"@formatjs/intl-localematcher": "0.2.
|
|
25
|
+
"@formatjs/ecma402-abstract": "1.11.0",
|
|
26
|
+
"@formatjs/intl-localematcher": "0.2.21",
|
|
27
27
|
"tslib": "^2.1.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/polyfill-force.js
CHANGED
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var _1 = require("./");
|
|
4
4
|
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
5
|
var to_locale_string_1 = require("./src/to_locale_string");
|
|
6
|
-
ecma402_abstract_1.defineProperty(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
|
|
7
|
-
ecma402_abstract_1.defineProperty(Date.prototype, 'toLocaleString', {
|
|
6
|
+
(0, ecma402_abstract_1.defineProperty)(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
|
|
7
|
+
(0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleString', {
|
|
8
8
|
value: function toLocaleString(locales, options) {
|
|
9
|
-
return to_locale_string_1.toLocaleString(this, locales, options);
|
|
9
|
+
return (0, to_locale_string_1.toLocaleString)(this, locales, options);
|
|
10
10
|
},
|
|
11
11
|
});
|
|
12
|
-
ecma402_abstract_1.defineProperty(Date.prototype, 'toLocaleDateString', {
|
|
12
|
+
(0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleDateString', {
|
|
13
13
|
value: function toLocaleDateString(locales, options) {
|
|
14
|
-
return to_locale_string_1.toLocaleDateString(this, locales, options);
|
|
14
|
+
return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
|
-
ecma402_abstract_1.defineProperty(Date.prototype, 'toLocaleTimeString', {
|
|
17
|
+
(0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleTimeString', {
|
|
18
18
|
value: function toLocaleTimeString(locales, options) {
|
|
19
|
-
return to_locale_string_1.toLocaleTimeString(this, locales, options);
|
|
19
|
+
return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
|
|
20
20
|
},
|
|
21
21
|
});
|