i18n-timezones 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 onomojo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # i18n-timezones
2
+
3
+ > Localized timezone names for JavaScript and TypeScript -- 36 locales, 152 timezones, zero dependencies.
4
+
5
+ Building a timezone picker for an international audience? Displaying meeting times across regions? The `Intl` API gives you raw IANA identifiers like `America/New_York`, but your users expect to see **"Eastern Time (US & Canada)"** -- in their own language.
6
+
7
+ **i18n-timezones** provides human-friendly, localized timezone display names sourced from [CLDR](https://cldr.unicode.org/), the same data that powers ICU, Chrome, and Android. It accepts both friendly timezone names and IANA timezone identifiers, giving you everything you need to build polished, multilingual timezone UIs.
8
+
9
+ ## Why i18n-timezones?
10
+
11
+ - **36 locales** covering 4+ billion speakers -- from Arabic to Vietnamese
12
+ - **Zero dependencies** -- just translation data and lookup functions
13
+ - **Tree-shakeable** -- bundle only the locales you need (~3-5 KB each, gzipped)
14
+ - **Dual ESM + CJS** -- works everywhere: Vite, Webpack, Next.js, Node.js
15
+ - **Full TypeScript** -- native type declarations, not bolted on
16
+ - **Friendly names + IANA** -- accepts both `"Tokyo"` and `"Asia/Tokyo"`, converts between them
17
+ - **Dropdown-ready** -- `getTimezoneList()` returns entries sorted by UTC offset, perfect for `<select>` menus
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install i18n-timezones
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ The fastest way to get going -- register all locales at once and set a default:
28
+
29
+ ```typescript
30
+ import { registerAllLocales, setDefaultLocale, getTimezoneName } from 'i18n-timezones';
31
+ import allLocales from 'i18n-timezones/langs/all.json';
32
+
33
+ registerAllLocales(allLocales);
34
+ setDefaultLocale('de');
35
+
36
+ getTimezoneName('Tokyo'); // => "Tokio"
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### Bundle-conscious apps -- register only what you need
42
+
43
+ Each locale is a separate JSON file. Import only the ones your app requires -- bundlers will tree-shake the rest.
44
+
45
+ ```typescript
46
+ import { registerLocale, getTimezoneName, getTimezoneDisplay } from 'i18n-timezones';
47
+ import de from 'i18n-timezones/langs/de.json';
48
+ import fr from 'i18n-timezones/langs/fr.json';
49
+
50
+ registerLocale(de);
51
+ registerLocale(fr);
52
+
53
+ getTimezoneName('Tokyo', 'de'); // => "Tokio"
54
+ getTimezoneName('Asia/Tokyo', 'fr'); // => "Tokyo" (accepts IANA IDs too)
55
+ getTimezoneDisplay('Tokyo', 'de'); // => "(GMT+09:00) Tokio"
56
+ ```
57
+
58
+ ### Using a default locale
59
+
60
+ Set a default locale so you don't have to pass it every time:
61
+
62
+ ```typescript
63
+ import { registerLocale, setDefaultLocale, getDefaultLocale, getTimezoneName } from 'i18n-timezones';
64
+ import de from 'i18n-timezones/langs/de.json';
65
+
66
+ registerLocale(de);
67
+ setDefaultLocale('de');
68
+
69
+ getTimezoneName('Tokyo'); // => "Tokio" (uses default locale)
70
+ getTimezoneName('Tokyo', 'de'); // => "Tokio" (explicit locale still works)
71
+ getDefaultLocale(); // => "de"
72
+ ```
73
+
74
+ ### Building a timezone dropdown
75
+
76
+ ```typescript
77
+ import { registerLocale, getTimezoneList } from 'i18n-timezones';
78
+ import en from 'i18n-timezones/langs/en.json';
79
+
80
+ registerLocale(en);
81
+
82
+ const timezones = getTimezoneList('en');
83
+ // Returns an array sorted by UTC offset:
84
+ // [
85
+ // { key: "International Date Line West", iana: "Etc/GMT+12", name: "International Date Line West",
86
+ // display: "(GMT-12:00) International Date Line West", utcOffset: -720 },
87
+ // ...
88
+ // { key: "Tokyo", iana: "Asia/Tokyo", name: "Tokyo",
89
+ // display: "(GMT+09:00) Tokyo", utcOffset: 540 },
90
+ // ...
91
+ // ]
92
+
93
+ // Use it in a React component:
94
+ function TimezonePicker({ value, onChange }) {
95
+ return (
96
+ <select value={value} onChange={e => onChange(e.target.value)}>
97
+ {timezones.map(tz => (
98
+ <option key={tz.key} value={tz.iana ?? tz.key}>
99
+ {tz.display}
100
+ </option>
101
+ ))}
102
+ </select>
103
+ );
104
+ }
105
+ ```
106
+
107
+ ### Converting between friendly names and IANA IDs
108
+
109
+ ```typescript
110
+ import { getIanaTimezone, getTimezoneFriendlyName } from 'i18n-timezones';
111
+
112
+ getIanaTimezone('Eastern Time (US & Canada)'); // => "America/New_York"
113
+ getTimezoneFriendlyName('Asia/Tokyo'); // => "Osaka"
114
+ ```
115
+
116
+ ## API Reference
117
+
118
+ | Function | Description |
119
+ |----------|-------------|
120
+ | `registerLocale(data)` | Register a locale's timezone translations. Required before lookups. |
121
+ | `registerAllLocales(allData)` | Register an array of locale data objects at once. |
122
+ | `setDefaultLocale(locale)` | Set the default locale for lookup functions. Throws if locale is not registered. |
123
+ | `getDefaultLocale()` | Get the current default locale, or `undefined` if none is set. |
124
+ | `getTimezoneName(timezone, locale?)` | Get the localized name. Accepts friendly names or IANA IDs. Uses default locale if omitted. |
125
+ | `getTimezoneDisplay(timezone, locale?, options?)` | Formatted string like `"(GMT+09:00) Tokio"`. Options: `{ offsetFormat: 'GMT' \| 'UTC' }` |
126
+ | `getTimezoneList(locale?, options?)` | Sorted array of all timezones -- ready for dropdowns. |
127
+ | `getTimezoneNames(locale?)` | All translations as a `{ name: localizedName }` object. |
128
+ | `getIanaTimezone(friendlyName)` | Convert friendly name to IANA ID. |
129
+ | `getTimezoneFriendlyName(ianaId)` | Convert IANA ID to friendly name. |
130
+ | `getSupportedLocales()` | List all registered locale codes. |
131
+ | `isLocaleRegistered(locale)` | Check if a locale has been registered. |
132
+
133
+ All lookup functions return `undefined` when a timezone or locale is not found -- no exceptions thrown.
134
+
135
+ ## Supported Locales
136
+
137
+ 36 locales covering major world languages:
138
+
139
+ | | | | | | | |
140
+ |---|---|---|---|---|---|---|
141
+ | ar | bn | ca | cs | da | de | el |
142
+ | en | es | eu | fi | fr | he | hi |
143
+ | hr | hu | id | it | ja | ko | ms |
144
+ | nl | no | pl | pt | pt-BR | ro | ru |
145
+ | sq | sv | th | tr | uk | vi | zh-CN |
146
+ | zh-TW | | | | | | |
147
+
148
+ ## Data Source
149
+
150
+ All translations come from the [Unicode CLDR](https://cldr.unicode.org/) (Common Locale Data Repository) -- the industry-standard source used by every major platform including iOS, Android, Chrome, and Java. This ensures translations are accurate, consistent, and maintained by native speakers through Unicode's established review process.
151
+
152
+ ## Related
153
+
154
+ - **[i18n-country-translations](https://github.com/onomojo/i18n-country-translations-js)** -- Localized country names for 168 locales
155
+ - **[i18n-timezones-data](https://github.com/onomojo/i18n-timezones-data)** -- Raw YAML translation data (for non-JS consumers)
156
+
157
+ ## License
158
+
159
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,473 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ getDefaultLocale: () => getDefaultLocale,
24
+ getIanaTimezone: () => getIanaTimezone,
25
+ getSupportedLocales: () => getSupportedLocales,
26
+ getTimezoneDisplay: () => getTimezoneDisplay,
27
+ getTimezoneFriendlyName: () => getTimezoneFriendlyName,
28
+ getTimezoneList: () => getTimezoneList,
29
+ getTimezoneName: () => getTimezoneName,
30
+ getTimezoneNames: () => getTimezoneNames,
31
+ isLocaleRegistered: () => isLocaleRegistered,
32
+ registerAllLocales: () => registerAllLocales,
33
+ registerLocale: () => registerLocale,
34
+ setDefaultLocale: () => setDefaultLocale
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/registry.ts
39
+ var locales = /* @__PURE__ */ new Map();
40
+ var defaultLocale;
41
+ function registerLocale(data) {
42
+ if (!data || typeof data.locale !== "string" || data.locale.length === 0) {
43
+ throw new Error("registerLocale: data.locale must be a non-empty string");
44
+ }
45
+ if (!data.timezones || typeof data.timezones !== "object") {
46
+ throw new Error("registerLocale: data.timezones must be a non-null object");
47
+ }
48
+ locales.set(data.locale, data.timezones);
49
+ }
50
+ function registerAllLocales(allData) {
51
+ for (const data of allData) {
52
+ registerLocale(data);
53
+ }
54
+ }
55
+ function setDefaultLocale(locale) {
56
+ if (!locales.has(locale)) {
57
+ throw new Error(`setDefaultLocale: locale "${locale}" is not registered`);
58
+ }
59
+ defaultLocale = locale;
60
+ }
61
+ function getDefaultLocale() {
62
+ return defaultLocale;
63
+ }
64
+ function getSupportedLocales() {
65
+ return Array.from(locales.keys());
66
+ }
67
+ function isLocaleRegistered(locale) {
68
+ return locales.has(locale);
69
+ }
70
+ function getLocaleData(locale) {
71
+ return locales.get(locale);
72
+ }
73
+
74
+ // src/mapping.ts
75
+ var friendlyNameToIana = {
76
+ "International Date Line West": "Etc/GMT+12",
77
+ "American Samoa": "Pacific/Pago_Pago",
78
+ "Midway Island": "Pacific/Midway",
79
+ "Hawaii": "Pacific/Honolulu",
80
+ "Alaska": "America/Juneau",
81
+ "Pacific Time (US & Canada)": "America/Los_Angeles",
82
+ "Tijuana": "America/Tijuana",
83
+ "Arizona": "America/Phoenix",
84
+ "Mazatlan": "America/Mazatlan",
85
+ "Mountain Time (US & Canada)": "America/Denver",
86
+ "Central America": "America/Guatemala",
87
+ "Central Time (US & Canada)": "America/Chicago",
88
+ "Chihuahua": "America/Chihuahua",
89
+ "Guadalajara": "America/Mexico_City",
90
+ "Mexico City": "America/Mexico_City",
91
+ "Monterrey": "America/Monterrey",
92
+ "Saskatchewan": "America/Regina",
93
+ "Bogota": "America/Bogota",
94
+ "Eastern Time (US & Canada)": "America/New_York",
95
+ "Indiana (East)": "America/Indiana/Indianapolis",
96
+ "Lima": "America/Lima",
97
+ "Quito": "America/Lima",
98
+ "Asuncion": "America/Asuncion",
99
+ "Atlantic Time (Canada)": "America/Halifax",
100
+ "Caracas": "America/Caracas",
101
+ "Georgetown": "America/Guyana",
102
+ "La Paz": "America/La_Paz",
103
+ "Puerto Rico": "America/Puerto_Rico",
104
+ "Santiago": "America/Santiago",
105
+ "Newfoundland": "America/St_Johns",
106
+ "Brasilia": "America/Sao_Paulo",
107
+ "Buenos Aires": "America/Argentina/Buenos_Aires",
108
+ "Montevideo": "America/Montevideo",
109
+ "Greenland": "America/Godthab",
110
+ "Mid-Atlantic": "Atlantic/South_Georgia",
111
+ "Azores": "Atlantic/Azores",
112
+ "Cape Verde Is.": "Atlantic/Cape_Verde",
113
+ "Edinburgh": "Europe/London",
114
+ "Lisbon": "Europe/Lisbon",
115
+ "London": "Europe/London",
116
+ "Monrovia": "Africa/Monrovia",
117
+ "UTC": "Etc/UTC",
118
+ "Amsterdam": "Europe/Amsterdam",
119
+ "Belgrade": "Europe/Belgrade",
120
+ "Berlin": "Europe/Berlin",
121
+ "Bern": "Europe/Zurich",
122
+ "Bratislava": "Europe/Bratislava",
123
+ "Brussels": "Europe/Brussels",
124
+ "Budapest": "Europe/Budapest",
125
+ "Casablanca": "Africa/Casablanca",
126
+ "Copenhagen": "Europe/Copenhagen",
127
+ "Dublin": "Europe/Dublin",
128
+ "Ljubljana": "Europe/Ljubljana",
129
+ "Madrid": "Europe/Madrid",
130
+ "Paris": "Europe/Paris",
131
+ "Prague": "Europe/Prague",
132
+ "Rome": "Europe/Rome",
133
+ "Sarajevo": "Europe/Sarajevo",
134
+ "Skopje": "Europe/Skopje",
135
+ "Stockholm": "Europe/Stockholm",
136
+ "Vienna": "Europe/Vienna",
137
+ "Warsaw": "Europe/Warsaw",
138
+ "West Central Africa": "Africa/Algiers",
139
+ "Zagreb": "Europe/Zagreb",
140
+ "Zurich": "Europe/Zurich",
141
+ "Athens": "Europe/Athens",
142
+ "Bucharest": "Europe/Bucharest",
143
+ "Cairo": "Africa/Cairo",
144
+ "Harare": "Africa/Harare",
145
+ "Helsinki": "Europe/Helsinki",
146
+ "Jerusalem": "Asia/Jerusalem",
147
+ "Kaliningrad": "Europe/Kaliningrad",
148
+ "Kyiv": "Europe/Kyiv",
149
+ "Pretoria": "Africa/Johannesburg",
150
+ "Riga": "Europe/Riga",
151
+ "Sofia": "Europe/Sofia",
152
+ "Tallinn": "Europe/Tallinn",
153
+ "Vilnius": "Europe/Vilnius",
154
+ "Baghdad": "Asia/Baghdad",
155
+ "Istanbul": "Europe/Istanbul",
156
+ "Kuwait": "Asia/Kuwait",
157
+ "Minsk": "Europe/Minsk",
158
+ "Moscow": "Europe/Moscow",
159
+ "Nairobi": "Africa/Nairobi",
160
+ "Riyadh": "Asia/Riyadh",
161
+ "St. Petersburg": "Europe/Moscow",
162
+ "Volgograd": "Europe/Volgograd",
163
+ "Tehran": "Asia/Tehran",
164
+ "Abu Dhabi": "Asia/Muscat",
165
+ "Baku": "Asia/Baku",
166
+ "Muscat": "Asia/Muscat",
167
+ "Samara": "Europe/Samara",
168
+ "Tbilisi": "Asia/Tbilisi",
169
+ "Yerevan": "Asia/Yerevan",
170
+ "Kabul": "Asia/Kabul",
171
+ "Ekaterinburg": "Asia/Yekaterinburg",
172
+ "Islamabad": "Asia/Karachi",
173
+ "Karachi": "Asia/Karachi",
174
+ "Tashkent": "Asia/Tashkent",
175
+ "Chennai": "Asia/Kolkata",
176
+ "Kolkata": "Asia/Kolkata",
177
+ "Mumbai": "Asia/Kolkata",
178
+ "New Delhi": "Asia/Kolkata",
179
+ "Sri Jayawardenepura": "Asia/Colombo",
180
+ "Kathmandu": "Asia/Kathmandu",
181
+ "Almaty": "Asia/Almaty",
182
+ "Astana": "Asia/Dhaka",
183
+ "Dhaka": "Asia/Dhaka",
184
+ "Urumqi": "Asia/Urumqi",
185
+ "Rangoon": "Asia/Rangoon",
186
+ "Bangkok": "Asia/Bangkok",
187
+ "Hanoi": "Asia/Bangkok",
188
+ "Jakarta": "Asia/Jakarta",
189
+ "Krasnoyarsk": "Asia/Krasnoyarsk",
190
+ "Novosibirsk": "Asia/Novosibirsk",
191
+ "Beijing": "Asia/Shanghai",
192
+ "Chongqing": "Asia/Chongqing",
193
+ "Hong Kong": "Asia/Hong_Kong",
194
+ "Irkutsk": "Asia/Irkutsk",
195
+ "Kuala Lumpur": "Asia/Kuala_Lumpur",
196
+ "Perth": "Australia/Perth",
197
+ "Singapore": "Asia/Singapore",
198
+ "Taipei": "Asia/Taipei",
199
+ "Ulaanbaatar": "Asia/Ulaanbaatar",
200
+ "Osaka": "Asia/Tokyo",
201
+ "Sapporo": "Asia/Tokyo",
202
+ "Seoul": "Asia/Seoul",
203
+ "Tokyo": "Asia/Tokyo",
204
+ "Yakutsk": "Asia/Yakutsk",
205
+ "Adelaide": "Australia/Adelaide",
206
+ "Darwin": "Australia/Darwin",
207
+ "Brisbane": "Australia/Brisbane",
208
+ "Canberra": "Australia/Melbourne",
209
+ "Guam": "Pacific/Guam",
210
+ "Hobart": "Australia/Hobart",
211
+ "Melbourne": "Australia/Melbourne",
212
+ "Port Moresby": "Pacific/Port_Moresby",
213
+ "Sydney": "Australia/Sydney",
214
+ "Vladivostok": "Asia/Vladivostok",
215
+ "Magadan": "Asia/Magadan",
216
+ "New Caledonia": "Pacific/Noumea",
217
+ "Solomon Is.": "Pacific/Guadalcanal",
218
+ "Srednekolymsk": "Asia/Srednekolymsk",
219
+ "Auckland": "Pacific/Auckland",
220
+ "Fiji": "Pacific/Fiji",
221
+ "Kamchatka": "Asia/Kamchatka",
222
+ "Marshall Is.": "Pacific/Majuro",
223
+ "Wellington": "Pacific/Auckland",
224
+ "Chatham Is.": "Pacific/Chatham",
225
+ "Nuku'alofa": "Pacific/Tongatapu",
226
+ "Samoa": "Pacific/Apia",
227
+ "Tokelau Is.": "Pacific/Fakaofo"
228
+ };
229
+ var ianaToFriendlyName = {};
230
+ for (const [name, iana] of Object.entries(friendlyNameToIana)) {
231
+ if (!(iana in ianaToFriendlyName)) {
232
+ ianaToFriendlyName[iana] = name;
233
+ }
234
+ }
235
+ var utcOffsets = {
236
+ "International Date Line West": -720,
237
+ "American Samoa": -660,
238
+ "Midway Island": -660,
239
+ "Hawaii": -600,
240
+ "Alaska": -540,
241
+ "Pacific Time (US & Canada)": -480,
242
+ "Tijuana": -480,
243
+ "Arizona": -420,
244
+ "Mazatlan": -420,
245
+ "Mountain Time (US & Canada)": -420,
246
+ "Central America": -360,
247
+ "Central Time (US & Canada)": -360,
248
+ "Chihuahua": -360,
249
+ "Guadalajara": -360,
250
+ "Mexico City": -360,
251
+ "Monterrey": -360,
252
+ "Saskatchewan": -360,
253
+ "Bogota": -300,
254
+ "Eastern Time (US & Canada)": -300,
255
+ "Indiana (East)": -300,
256
+ "Lima": -300,
257
+ "Quito": -300,
258
+ "Asuncion": -240,
259
+ "Atlantic Time (Canada)": -240,
260
+ "Caracas": -240,
261
+ "Georgetown": -240,
262
+ "La Paz": -240,
263
+ "Puerto Rico": -240,
264
+ "Santiago": -240,
265
+ "Newfoundland": -210,
266
+ "Brasilia": -180,
267
+ "Buenos Aires": -180,
268
+ "Montevideo": -180,
269
+ "Greenland": -180,
270
+ "Mid-Atlantic": -120,
271
+ "Azores": -60,
272
+ "Cape Verde Is.": -60,
273
+ "Edinburgh": 0,
274
+ "Lisbon": 0,
275
+ "London": 0,
276
+ "Monrovia": 0,
277
+ "UTC": 0,
278
+ "Amsterdam": 60,
279
+ "Belgrade": 60,
280
+ "Berlin": 60,
281
+ "Bern": 60,
282
+ "Bratislava": 60,
283
+ "Brussels": 60,
284
+ "Budapest": 60,
285
+ "Casablanca": 60,
286
+ "Copenhagen": 60,
287
+ "Dublin": 60,
288
+ "Ljubljana": 60,
289
+ "Madrid": 60,
290
+ "Paris": 60,
291
+ "Prague": 60,
292
+ "Rome": 60,
293
+ "Sarajevo": 60,
294
+ "Skopje": 60,
295
+ "Stockholm": 60,
296
+ "Vienna": 60,
297
+ "Warsaw": 60,
298
+ "West Central Africa": 60,
299
+ "Zagreb": 60,
300
+ "Zurich": 60,
301
+ "Athens": 120,
302
+ "Bucharest": 120,
303
+ "Cairo": 120,
304
+ "Harare": 120,
305
+ "Helsinki": 120,
306
+ "Jerusalem": 120,
307
+ "Kaliningrad": 120,
308
+ "Kyiv": 120,
309
+ "Pretoria": 120,
310
+ "Riga": 120,
311
+ "Sofia": 120,
312
+ "Tallinn": 120,
313
+ "Vilnius": 120,
314
+ "Baghdad": 180,
315
+ "Istanbul": 180,
316
+ "Kuwait": 180,
317
+ "Minsk": 180,
318
+ "Moscow": 180,
319
+ "Nairobi": 180,
320
+ "Riyadh": 180,
321
+ "St. Petersburg": 180,
322
+ "Volgograd": 180,
323
+ "Tehran": 210,
324
+ "Abu Dhabi": 240,
325
+ "Baku": 240,
326
+ "Muscat": 240,
327
+ "Samara": 240,
328
+ "Tbilisi": 240,
329
+ "Yerevan": 240,
330
+ "Kabul": 270,
331
+ "Ekaterinburg": 300,
332
+ "Islamabad": 300,
333
+ "Karachi": 300,
334
+ "Tashkent": 300,
335
+ "Chennai": 330,
336
+ "Kolkata": 330,
337
+ "Mumbai": 330,
338
+ "New Delhi": 330,
339
+ "Sri Jayawardenepura": 330,
340
+ "Kathmandu": 345,
341
+ "Almaty": 360,
342
+ "Astana": 360,
343
+ "Dhaka": 360,
344
+ "Urumqi": 360,
345
+ "Rangoon": 390,
346
+ "Bangkok": 420,
347
+ "Hanoi": 420,
348
+ "Jakarta": 420,
349
+ "Krasnoyarsk": 420,
350
+ "Novosibirsk": 420,
351
+ "Beijing": 480,
352
+ "Chongqing": 480,
353
+ "Hong Kong": 480,
354
+ "Irkutsk": 480,
355
+ "Kuala Lumpur": 480,
356
+ "Perth": 480,
357
+ "Singapore": 480,
358
+ "Taipei": 480,
359
+ "Ulaanbaatar": 480,
360
+ "Osaka": 540,
361
+ "Sapporo": 540,
362
+ "Seoul": 540,
363
+ "Tokyo": 540,
364
+ "Yakutsk": 540,
365
+ "Adelaide": 570,
366
+ "Darwin": 570,
367
+ "Brisbane": 600,
368
+ "Canberra": 600,
369
+ "Guam": 600,
370
+ "Hobart": 600,
371
+ "Melbourne": 600,
372
+ "Port Moresby": 600,
373
+ "Sydney": 600,
374
+ "Vladivostok": 600,
375
+ "Magadan": 660,
376
+ "New Caledonia": 660,
377
+ "Solomon Is.": 660,
378
+ "Srednekolymsk": 660,
379
+ "Auckland": 720,
380
+ "Fiji": 720,
381
+ "Kamchatka": 720,
382
+ "Marshall Is.": 720,
383
+ "Wellington": 720,
384
+ "Chatham Is.": 765,
385
+ "Nuku'alofa": 780,
386
+ "Samoa": 780,
387
+ "Tokelau Is.": 780
388
+ };
389
+ function getIanaTimezone(friendlyName) {
390
+ return friendlyNameToIana[friendlyName];
391
+ }
392
+ function getTimezoneFriendlyName(ianaId) {
393
+ return ianaToFriendlyName[ianaId];
394
+ }
395
+ function resolveToFriendlyName(timezone) {
396
+ if (timezone in friendlyNameToIana) return timezone;
397
+ return ianaToFriendlyName[timezone];
398
+ }
399
+ function getUtcOffset(friendlyName) {
400
+ return utcOffsets[friendlyName];
401
+ }
402
+ function formatOffset(minutes, format = "GMT") {
403
+ const sign = minutes >= 0 ? "+" : "-";
404
+ const abs = Math.abs(minutes);
405
+ const h = String(Math.floor(abs / 60)).padStart(2, "0");
406
+ const m = String(abs % 60).padStart(2, "0");
407
+ return `${format}${sign}${h}:${m}`;
408
+ }
409
+
410
+ // src/lookup.ts
411
+ function resolveLocale(locale) {
412
+ return locale ?? getDefaultLocale();
413
+ }
414
+ function getTimezoneName(timezone, locale) {
415
+ const loc = resolveLocale(locale);
416
+ if (!loc) return void 0;
417
+ const data = getLocaleData(loc);
418
+ if (!data) return void 0;
419
+ const key = resolveToFriendlyName(timezone);
420
+ if (!key) return void 0;
421
+ return data[key];
422
+ }
423
+ function getTimezoneDisplay(timezone, locale, options) {
424
+ const loc = resolveLocale(locale);
425
+ if (!loc) return void 0;
426
+ const key = resolveToFriendlyName(timezone);
427
+ if (!key) return void 0;
428
+ const name = getTimezoneName(key, loc);
429
+ if (!name) return void 0;
430
+ const offset = getUtcOffset(key);
431
+ if (offset === void 0) return name;
432
+ return `(${formatOffset(offset, options?.offsetFormat ?? "GMT")}) ${name}`;
433
+ }
434
+ function getTimezoneNames(locale) {
435
+ const loc = resolveLocale(locale);
436
+ if (!loc) return void 0;
437
+ const data = getLocaleData(loc);
438
+ if (!data) return void 0;
439
+ return { ...data };
440
+ }
441
+ function getTimezoneList(locale, options) {
442
+ const loc = resolveLocale(locale);
443
+ if (!loc) return void 0;
444
+ const data = getLocaleData(loc);
445
+ if (!data) return void 0;
446
+ const entries = Object.entries(data).map(([key, name]) => {
447
+ const offset = getUtcOffset(key) ?? 0;
448
+ return {
449
+ key,
450
+ iana: getIanaTimezone(key),
451
+ name,
452
+ display: `(${formatOffset(offset, options?.offsetFormat ?? "GMT")}) ${name}`,
453
+ utcOffset: offset
454
+ };
455
+ });
456
+ return entries.sort((a, b) => a.utcOffset - b.utcOffset);
457
+ }
458
+ // Annotate the CommonJS export names for ESM import in node:
459
+ 0 && (module.exports = {
460
+ getDefaultLocale,
461
+ getIanaTimezone,
462
+ getSupportedLocales,
463
+ getTimezoneDisplay,
464
+ getTimezoneFriendlyName,
465
+ getTimezoneList,
466
+ getTimezoneName,
467
+ getTimezoneNames,
468
+ isLocaleRegistered,
469
+ registerAllLocales,
470
+ registerLocale,
471
+ setDefaultLocale
472
+ });
473
+ //# sourceMappingURL=index.cjs.map