@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.
- package/index.d.ts +5 -5
- package/index.js +5 -5
- package/package.json +2 -2
- package/src/countryCodes.d.ts +4 -4
- package/src/countryCodes.js +15 -15
- package/src/currencyMinorUnits.generated.d.ts +167 -166
- package/src/currencyMinorUnits.generated.js +166 -166
- package/src/defaultCurrency.d.ts +8 -8
- package/src/defaultCurrency.js +20 -20
- package/src/defaultCurrencyData.generated.d.ts +257 -256
- package/src/defaultCurrencyData.generated.js +256 -256
- package/src/defaultLocale.d.ts +4 -4
- package/src/defaultLocale.js +8 -8
- package/src/defaultLocaleData.generated.d.ts +193 -192
- package/src/defaultLocaleData.generated.js +192 -192
- package/src/defaultTimezone.d.ts +5 -5
- package/src/defaultTimezone.js +32 -47
- package/src/iso3166Alpha3CountryCodes.d.ts +239 -239
- package/src/iso3166Alpha3CountryCodes.js +239 -239
- package/src/iso4217.d.ts +8 -8
- package/src/iso4217.js +21 -21
|
@@ -1,195 +1,195 @@
|
|
|
1
1
|
// This is a generated file. Do not edit directly.
|
|
2
2
|
export default {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
};
|
package/src/defaultTimezone.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
type DTFParameters = ConstructorParameters<typeof Intl.DateTimeFormat>;
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function defaultTimezone(locales?: DTFParameters[0], options?: Pick<Intl.DateTimeFormatOptions,
|
|
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 {};
|
package/src/defaultTimezone.js
CHANGED
|
@@ -1,53 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var cache = {};
|
|
1
|
+
import { memoize, strategies } from "@formatjs/fast-memoize";
|
|
2
|
+
const cache = {};
|
|
4
3
|
function createFastMemoizeCache(store) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
19
|
+
const now = Date.now();
|
|
30
20
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
}
|