@formatjs/utils 2.1.0 → 2.1.2

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.
@@ -1,195 +1,195 @@
1
1
  // This is a generated file. Do not edit directly.
2
2
  export default {
3
- "AD": "ca-Latn-AD",
4
- "AE": "ar-Arab-AE",
5
- "AF": "fa-Arab-AF",
6
- "AL": "sq-Latn-AL",
7
- "AM": "hy-Armn-AM",
8
- "AO": "pt-Latn-AO",
9
- "AR": "es-Latn-AR",
10
- "AS": "sm-Latn-AS",
11
- "AT": "de-Latn-AT",
12
- "AW": "nl-Latn-AW",
13
- "AX": "sv-Latn-AX",
14
- "AZ": "az-Latn-AZ",
15
- "BA": "bs-Latn-BA",
16
- "BD": "bn-Beng-BD",
17
- "BE": "nl-Latn-BE",
18
- "BF": "fr-Latn-BF",
19
- "BG": "bg-Cyrl-BG",
20
- "BH": "ar-Arab-BH",
21
- "BI": "rn-Latn-BI",
22
- "BJ": "fr-Latn-BJ",
23
- "BL": "fr-Latn-BL",
24
- "BN": "ms-Latn-BN",
25
- "BO": "es-Latn-BO",
26
- "BQ": "pap-Latn-BQ",
27
- "BR": "pt-Latn-BR",
28
- "BT": "dz-Tibt-BT",
29
- "BV": "no-Latn-BV",
30
- "BY": "ru-Cyrl-BY",
31
- "CC": "ms-Arab-CC",
32
- "CD": "fr-Latn-CD",
33
- "CF": "sg-Latn-CF",
34
- "CG": "fr-Latn-CG",
35
- "CH": "de-Latn-CH",
36
- "CI": "fr-Latn-CI",
37
- "CL": "es-Latn-CL",
38
- "CM": "fr-Latn-CM",
39
- "CN": "zh-Hans-CN",
40
- "CO": "es-Latn-CO",
41
- "CR": "es-Latn-CR",
42
- "CU": "es-Latn-CU",
43
- "CV": "pt-Latn-CV",
44
- "CW": "pap-Latn-CW",
45
- "CY": "el-Grek-CY",
46
- "CZ": "cs-Latn-CZ",
47
- "DE": "de-Latn-DE",
48
- "DJ": "fr-Latn-DJ",
49
- "DK": "da-Latn-DK",
50
- "DO": "es-Latn-DO",
51
- "DZ": "ar-Arab-DZ",
52
- "EA": "es-Latn-EA",
53
- "EC": "es-Latn-EC",
54
- "EE": "et-Latn-EE",
55
- "EG": "ar-Arab-EG",
56
- "EH": "ar-Arab-EH",
57
- "ER": "ti-Ethi-ER",
58
- "ES": "es-Latn-ES",
59
- "ET": "am-Ethi-ET",
60
- "FI": "fi-Latn-FI",
61
- "FO": "fo-Latn-FO",
62
- "FR": "fr-Latn-FR",
63
- "GA": "fr-Latn-GA",
64
- "GE": "ka-Geor-GE",
65
- "GF": "fr-Latn-GF",
66
- "GH": "ak-Latn-GH",
67
- "GL": "kl-Latn-GL",
68
- "GN": "fr-Latn-GN",
69
- "GP": "fr-Latn-GP",
70
- "GQ": "es-Latn-GQ",
71
- "GR": "el-Grek-GR",
72
- "GT": "es-Latn-GT",
73
- "GW": "pt-Latn-GW",
74
- "HK": "zh-Hant-HK",
75
- "HN": "es-Latn-HN",
76
- "HR": "hr-Latn-HR",
77
- "HT": "ht-Latn-HT",
78
- "HU": "hu-Latn-HU",
79
- "IC": "es-Latn-IC",
80
- "ID": "id-Latn-ID",
81
- "IL": "he-Hebr-IL",
82
- "IN": "hi-Deva-IN",
83
- "IQ": "ar-Arab-IQ",
84
- "IR": "fa-Arab-IR",
85
- "IS": "is-Latn-IS",
86
- "IT": "it-Latn-IT",
87
- "JO": "ar-Arab-JO",
88
- "JP": "ja-Jpan-JP",
89
- "KE": "sw-Latn-KE",
90
- "KG": "ky-Cyrl-KG",
91
- "KH": "km-Khmr-KH",
92
- "KM": "ar-Arab-KM",
93
- "KP": "ko-Kore-KP",
94
- "KR": "ko-Kore-KR",
95
- "KW": "ar-Arab-KW",
96
- "KZ": "ru-Cyrl-KZ",
97
- "LA": "lo-Laoo-LA",
98
- "LB": "ar-Arab-LB",
99
- "LI": "de-Latn-LI",
100
- "LK": "si-Sinh-LK",
101
- "LS": "st-Latn-LS",
102
- "LT": "lt-Latn-LT",
103
- "LU": "fr-Latn-LU",
104
- "LV": "lv-Latn-LV",
105
- "LY": "ar-Arab-LY",
106
- "MA": "ar-Arab-MA",
107
- "MC": "fr-Latn-MC",
108
- "MD": "ro-Latn-MD",
109
- "ME": "sr-Latn-ME",
110
- "MF": "fr-Latn-MF",
111
- "MG": "mg-Latn-MG",
112
- "MK": "mk-Cyrl-MK",
113
- "ML": "bm-Latn-ML",
114
- "MM": "my-Mymr-MM",
115
- "MN": "mn-Cyrl-MN",
116
- "MO": "zh-Hant-MO",
117
- "MQ": "fr-Latn-MQ",
118
- "MR": "ar-Arab-MR",
119
- "MT": "mt-Latn-MT",
120
- "MU": "fr-Latn-MU",
121
- "MV": "dv-Thaa-MV",
122
- "MX": "es-Latn-MX",
123
- "MY": "ms-Latn-MY",
124
- "MZ": "pt-Latn-MZ",
125
- "NA": "af-Latn-NA",
126
- "NC": "fr-Latn-NC",
127
- "NE": "ha-Latn-NE",
128
- "NI": "es-Latn-NI",
129
- "NL": "nl-Latn-NL",
130
- "NO": "nb-Latn-NO",
131
- "NP": "ne-Deva-NP",
132
- "OM": "ar-Arab-OM",
133
- "PA": "es-Latn-PA",
134
- "PE": "es-Latn-PE",
135
- "PF": "fr-Latn-PF",
136
- "PG": "tpi-Latn-PG",
137
- "PH": "fil-Latn-PH",
138
- "PK": "ur-Arab-PK",
139
- "PL": "pl-Latn-PL",
140
- "PM": "fr-Latn-PM",
141
- "PR": "es-Latn-PR",
142
- "PS": "ar-Arab-PS",
143
- "PT": "pt-Latn-PT",
144
- "PW": "pau-Latn-PW",
145
- "PY": "gn-Latn-PY",
146
- "QA": "ar-Arab-QA",
147
- "RE": "fr-Latn-RE",
148
- "RO": "ro-Latn-RO",
149
- "RS": "sr-Cyrl-RS",
150
- "RU": "ru-Cyrl-RU",
151
- "RW": "rw-Latn-RW",
152
- "SA": "ar-Arab-SA",
153
- "SC": "fr-Latn-SC",
154
- "SD": "ar-Arab-SD",
155
- "SE": "sv-Latn-SE",
156
- "SI": "sl-Latn-SI",
157
- "SJ": "nb-Latn-SJ",
158
- "SK": "sk-Latn-SK",
159
- "SM": "it-Latn-SM",
160
- "SN": "wo-Latn-SN",
161
- "SO": "so-Latn-SO",
162
- "SR": "nl-Latn-SR",
163
- "SS": "ar-Arab-SS",
164
- "ST": "pt-Latn-ST",
165
- "SV": "es-Latn-SV",
166
- "SY": "ar-Arab-SY",
167
- "TD": "ar-Arab-TD",
168
- "TF": "fr-Latn-TF",
169
- "TG": "fr-Latn-TG",
170
- "TH": "th-Thai-TH",
171
- "TJ": "tg-Cyrl-TJ",
172
- "TK": "tkl-Latn-TK",
173
- "TL": "pt-Latn-TL",
174
- "TM": "tk-Latn-TM",
175
- "TN": "ar-Arab-TN",
176
- "TO": "to-Latn-TO",
177
- "TR": "tr-Latn-TR",
178
- "TV": "tvl-Latn-TV",
179
- "TW": "zh-Hant-TW",
180
- "TZ": "sw-Latn-TZ",
181
- "UA": "uk-Cyrl-UA",
182
- "UG": "sw-Latn-UG",
183
- "UY": "es-Latn-UY",
184
- "UZ": "uz-Latn-UZ",
185
- "VA": "it-Latn-VA",
186
- "VE": "es-Latn-VE",
187
- "VN": "vi-Latn-VN",
188
- "VU": "bi-Latn-VU",
189
- "WF": "fr-Latn-WF",
190
- "WS": "sm-Latn-WS",
191
- "XK": "sq-Latn-XK",
192
- "YE": "ar-Arab-YE",
193
- "YT": "fr-Latn-YT",
194
- "ZW": "sn-Latn-ZW"
3
+ AD: "ca-Latn-AD",
4
+ AE: "ar-Arab-AE",
5
+ AF: "fa-Arab-AF",
6
+ AL: "sq-Latn-AL",
7
+ AM: "hy-Armn-AM",
8
+ AO: "pt-Latn-AO",
9
+ AR: "es-Latn-AR",
10
+ AS: "sm-Latn-AS",
11
+ AT: "de-Latn-AT",
12
+ AW: "nl-Latn-AW",
13
+ AX: "sv-Latn-AX",
14
+ AZ: "az-Latn-AZ",
15
+ BA: "bs-Latn-BA",
16
+ BD: "bn-Beng-BD",
17
+ BE: "nl-Latn-BE",
18
+ BF: "fr-Latn-BF",
19
+ BG: "bg-Cyrl-BG",
20
+ BH: "ar-Arab-BH",
21
+ BI: "rn-Latn-BI",
22
+ BJ: "fr-Latn-BJ",
23
+ BL: "fr-Latn-BL",
24
+ BN: "ms-Latn-BN",
25
+ BO: "es-Latn-BO",
26
+ BQ: "pap-Latn-BQ",
27
+ BR: "pt-Latn-BR",
28
+ BT: "dz-Tibt-BT",
29
+ BV: "no-Latn-BV",
30
+ BY: "ru-Cyrl-BY",
31
+ CC: "ms-Arab-CC",
32
+ CD: "fr-Latn-CD",
33
+ CF: "sg-Latn-CF",
34
+ CG: "fr-Latn-CG",
35
+ CH: "de-Latn-CH",
36
+ CI: "fr-Latn-CI",
37
+ CL: "es-Latn-CL",
38
+ CM: "fr-Latn-CM",
39
+ CN: "zh-Hans-CN",
40
+ CO: "es-Latn-CO",
41
+ CR: "es-Latn-CR",
42
+ CU: "es-Latn-CU",
43
+ CV: "pt-Latn-CV",
44
+ CW: "pap-Latn-CW",
45
+ CY: "el-Grek-CY",
46
+ CZ: "cs-Latn-CZ",
47
+ DE: "de-Latn-DE",
48
+ DJ: "fr-Latn-DJ",
49
+ DK: "da-Latn-DK",
50
+ DO: "es-Latn-DO",
51
+ DZ: "ar-Arab-DZ",
52
+ EA: "es-Latn-EA",
53
+ EC: "es-Latn-EC",
54
+ EE: "et-Latn-EE",
55
+ EG: "ar-Arab-EG",
56
+ EH: "ar-Arab-EH",
57
+ ER: "ti-Ethi-ER",
58
+ ES: "es-Latn-ES",
59
+ ET: "am-Ethi-ET",
60
+ FI: "fi-Latn-FI",
61
+ FO: "fo-Latn-FO",
62
+ FR: "fr-Latn-FR",
63
+ GA: "fr-Latn-GA",
64
+ GE: "ka-Geor-GE",
65
+ GF: "fr-Latn-GF",
66
+ GH: "ak-Latn-GH",
67
+ GL: "kl-Latn-GL",
68
+ GN: "fr-Latn-GN",
69
+ GP: "fr-Latn-GP",
70
+ GQ: "es-Latn-GQ",
71
+ GR: "el-Grek-GR",
72
+ GT: "es-Latn-GT",
73
+ GW: "pt-Latn-GW",
74
+ HK: "zh-Hant-HK",
75
+ HN: "es-Latn-HN",
76
+ HR: "hr-Latn-HR",
77
+ HT: "ht-Latn-HT",
78
+ HU: "hu-Latn-HU",
79
+ IC: "es-Latn-IC",
80
+ ID: "id-Latn-ID",
81
+ IL: "he-Hebr-IL",
82
+ IN: "hi-Deva-IN",
83
+ IQ: "ar-Arab-IQ",
84
+ IR: "fa-Arab-IR",
85
+ IS: "is-Latn-IS",
86
+ IT: "it-Latn-IT",
87
+ JO: "ar-Arab-JO",
88
+ JP: "ja-Jpan-JP",
89
+ KE: "sw-Latn-KE",
90
+ KG: "ky-Cyrl-KG",
91
+ KH: "km-Khmr-KH",
92
+ KM: "ar-Arab-KM",
93
+ KP: "ko-Kore-KP",
94
+ KR: "ko-Kore-KR",
95
+ KW: "ar-Arab-KW",
96
+ KZ: "ru-Cyrl-KZ",
97
+ LA: "lo-Laoo-LA",
98
+ LB: "ar-Arab-LB",
99
+ LI: "de-Latn-LI",
100
+ LK: "si-Sinh-LK",
101
+ LS: "st-Latn-LS",
102
+ LT: "lt-Latn-LT",
103
+ LU: "fr-Latn-LU",
104
+ LV: "lv-Latn-LV",
105
+ LY: "ar-Arab-LY",
106
+ MA: "ar-Arab-MA",
107
+ MC: "fr-Latn-MC",
108
+ MD: "ro-Latn-MD",
109
+ ME: "sr-Latn-ME",
110
+ MF: "fr-Latn-MF",
111
+ MG: "mg-Latn-MG",
112
+ MK: "mk-Cyrl-MK",
113
+ ML: "bm-Latn-ML",
114
+ MM: "my-Mymr-MM",
115
+ MN: "mn-Cyrl-MN",
116
+ MO: "zh-Hant-MO",
117
+ MQ: "fr-Latn-MQ",
118
+ MR: "ar-Arab-MR",
119
+ MT: "mt-Latn-MT",
120
+ MU: "fr-Latn-MU",
121
+ MV: "dv-Thaa-MV",
122
+ MX: "es-Latn-MX",
123
+ MY: "ms-Latn-MY",
124
+ MZ: "pt-Latn-MZ",
125
+ NA: "af-Latn-NA",
126
+ NC: "fr-Latn-NC",
127
+ NE: "ha-Latn-NE",
128
+ NI: "es-Latn-NI",
129
+ NL: "nl-Latn-NL",
130
+ NO: "nb-Latn-NO",
131
+ NP: "ne-Deva-NP",
132
+ OM: "ar-Arab-OM",
133
+ PA: "es-Latn-PA",
134
+ PE: "es-Latn-PE",
135
+ PF: "fr-Latn-PF",
136
+ PG: "tpi-Latn-PG",
137
+ PH: "fil-Latn-PH",
138
+ PK: "ur-Arab-PK",
139
+ PL: "pl-Latn-PL",
140
+ PM: "fr-Latn-PM",
141
+ PR: "es-Latn-PR",
142
+ PS: "ar-Arab-PS",
143
+ PT: "pt-Latn-PT",
144
+ PW: "pau-Latn-PW",
145
+ PY: "gn-Latn-PY",
146
+ QA: "ar-Arab-QA",
147
+ RE: "fr-Latn-RE",
148
+ RO: "ro-Latn-RO",
149
+ RS: "sr-Cyrl-RS",
150
+ RU: "ru-Cyrl-RU",
151
+ RW: "rw-Latn-RW",
152
+ SA: "ar-Arab-SA",
153
+ SC: "fr-Latn-SC",
154
+ SD: "ar-Arab-SD",
155
+ SE: "sv-Latn-SE",
156
+ SI: "sl-Latn-SI",
157
+ SJ: "nb-Latn-SJ",
158
+ SK: "sk-Latn-SK",
159
+ SM: "it-Latn-SM",
160
+ SN: "wo-Latn-SN",
161
+ SO: "so-Latn-SO",
162
+ SR: "nl-Latn-SR",
163
+ SS: "ar-Arab-SS",
164
+ ST: "pt-Latn-ST",
165
+ SV: "es-Latn-SV",
166
+ SY: "ar-Arab-SY",
167
+ TD: "ar-Arab-TD",
168
+ TF: "fr-Latn-TF",
169
+ TG: "fr-Latn-TG",
170
+ TH: "th-Thai-TH",
171
+ TJ: "tg-Cyrl-TJ",
172
+ TK: "tkl-Latn-TK",
173
+ TL: "pt-Latn-TL",
174
+ TM: "tk-Latn-TM",
175
+ TN: "ar-Arab-TN",
176
+ TO: "to-Latn-TO",
177
+ TR: "tr-Latn-TR",
178
+ TV: "tvl-Latn-TV",
179
+ TW: "zh-Hant-TW",
180
+ TZ: "sw-Latn-TZ",
181
+ UA: "uk-Cyrl-UA",
182
+ UG: "sw-Latn-UG",
183
+ UY: "es-Latn-UY",
184
+ UZ: "uz-Latn-UZ",
185
+ VA: "it-Latn-VA",
186
+ VE: "es-Latn-VE",
187
+ VN: "vi-Latn-VN",
188
+ VU: "bi-Latn-VU",
189
+ WF: "fr-Latn-WF",
190
+ WS: "sm-Latn-WS",
191
+ XK: "sq-Latn-XK",
192
+ YE: "ar-Arab-YE",
193
+ YT: "fr-Latn-YT",
194
+ ZW: "sn-Latn-ZW"
195
195
  };
@@ -1,8 +1,8 @@
1
1
  type DTFParameters = ConstructorParameters<typeof Intl.DateTimeFormat>;
2
2
  /**
3
- * Return the localized default timezone for the system. If `timeZoneName` is not supported, return the IANA timezone name.
4
- * @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
5
- * @returns default timezone for the system
6
- */
7
- export declare function defaultTimezone(locales?: DTFParameters[0], options?: Pick<Intl.DateTimeFormatOptions, 'timeZoneName'>): string;
3
+ * Return the localized default timezone for the system. If `timeZoneName` is not supported, return the IANA timezone name.
4
+ * @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
5
+ * @returns default timezone for the system
6
+ */
7
+ export declare function defaultTimezone(locales?: DTFParameters[0], options?: Pick<Intl.DateTimeFormatOptions, "timeZoneName">): string;
8
8
  export {};
@@ -1,53 +1,38 @@
1
- import { __spreadArray } from "tslib";
2
- import { memoize, strategies } from '@formatjs/fast-memoize';
3
- var cache = {};
1
+ import { memoize, strategies } from "@formatjs/fast-memoize";
2
+ const cache = {};
4
3
  function createFastMemoizeCache(store) {
5
- return {
6
- create: function () {
7
- return {
8
- get: function (key) {
9
- return store[key];
10
- },
11
- set: function (key, value) {
12
- store[key] = value;
13
- },
14
- };
15
- },
16
- };
4
+ return { create() {
5
+ return {
6
+ get(key) {
7
+ return store[key];
8
+ },
9
+ set(key, value) {
10
+ store[key] = value;
11
+ }
12
+ };
13
+ } };
17
14
  }
18
- var getDateTimeFormat = memoize(function () {
19
- var _a;
20
- var args = [];
21
- for (var _i = 0; _i < arguments.length; _i++) {
22
- args[_i] = arguments[_i];
23
- }
24
- return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
25
- }, {
26
- cache: createFastMemoizeCache(cache),
27
- strategy: strategies.variadic,
15
+ const getDateTimeFormat = memoize((...args) => new Intl.DateTimeFormat(...args), {
16
+ cache: createFastMemoizeCache(cache),
17
+ strategy: strategies.variadic
28
18
  });
29
- var now = Date.now();
19
+ const now = Date.now();
30
20
  /**
31
- * Return the localized default timezone for the system. If `timeZoneName` is not supported, return the IANA timezone name.
32
- * @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
33
- * @returns default timezone for the system
34
- */
21
+ * Return the localized default timezone for the system. If `timeZoneName` is not supported, return the IANA timezone name.
22
+ * @param dateDateTimeFormatCreator creator fn for Intl.DateTimeFormat
23
+ * @returns default timezone for the system
24
+ */
35
25
  export function defaultTimezone(locales, options) {
36
- var _a;
37
- var timeZoneName = options === null || options === void 0 ? void 0 : options.timeZoneName;
38
- try {
39
- var dtf = getDateTimeFormat(locales, {
40
- timeZoneName: options === null || options === void 0 ? void 0 : options.timeZoneName,
41
- });
42
- // If there's no `timeZoneName` specified, return the IANA timezone name
43
- if (!timeZoneName) {
44
- return dtf.resolvedOptions().timeZone;
45
- }
46
- // If `timeZoneName` is specified, return the localized timezone name
47
- return (((_a = dtf.formatToParts(now).find(function (p) { return p.type === 'timeZoneName'; })) === null || _a === void 0 ? void 0 : _a.value) ||
48
- 'UTC');
49
- }
50
- catch (_b) {
51
- return 'UTC';
52
- }
26
+ const timeZoneName = options?.timeZoneName;
27
+ try {
28
+ const dtf = getDateTimeFormat(locales, { timeZoneName: options?.timeZoneName });
29
+ // If there's no `timeZoneName` specified, return the IANA timezone name
30
+ if (!timeZoneName) {
31
+ return dtf.resolvedOptions().timeZone;
32
+ }
33
+ // If `timeZoneName` is specified, return the localized timezone name
34
+ return dtf.formatToParts(now).find((p) => p.type === "timeZoneName")?.value || "UTC";
35
+ } catch {
36
+ return "UTC";
37
+ }
53
38
  }