@vvo/tzdb 6.198.0 → 6.200.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/README.md +136 -135
- package/abbreviations.json +15 -0
- package/dist/index.cjs +4654 -0
- package/dist/index.d.cts +65 -0
- package/dist/index.d.ts +45 -8
- package/dist/index.js +4647 -34
- package/package.json +89 -120
- package/raw-time-zones.json +166 -167
- package/time-zones-names.json +1 -1
- package/dist/formatTimeZone.js +0 -26
- package/dist/formatTimeZone.js.map +0 -1
- package/dist/getTimeZones.js +0 -62
- package/dist/getTimeZones.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/timeZone.js +0 -99
- package/dist/utils/timeZone.js.map +0 -1
- package/index.d.ts +0 -28
- package/lib/formatTimeZone.js +0 -31
- package/lib/getTimeZones.js +0 -71
- package/lib/index.js +0 -4
- package/lib/utils/timeZone.js +0 -113
package/README.md
CHANGED
|
@@ -1,182 +1,183 @@
|
|
|
1
|
-
# tzdb [](https://www.npmjs.com/package/@vvo/tzdb)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Always up to date time zones for time zone pickers, and the country of any time zone.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
```js
|
|
6
|
+
import { getTimeZones } from "@vvo/tzdb";
|
|
7
|
+
|
|
8
|
+
getTimeZones().map((timeZone) => timeZone.currentTimeFormat);
|
|
9
|
+
// [..., "-07:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco", ...]
|
|
10
|
+
```
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
- Every [IANA time zone](https://www.iana.org/time-zones), grouped by country and clock, with major
|
|
13
|
+
cities.
|
|
14
|
+
- Current offsets and abbreviations: PDT in summer, PST in winter.
|
|
15
|
+
- Every current and deprecated IANA name, so saved values always find their entry.
|
|
16
|
+
- Names in any language the browser supports.
|
|
17
|
+
- The country of a visitor's time zone, to guess where they are without an IP lookup.
|
|
18
|
+
- No dependencies, ESM and CommonJS, TypeScript types.
|
|
11
19
|
|
|
12
|
-
|
|
20
|
+
## Always up to date
|
|
13
21
|
|
|
14
|
-
|
|
22
|
+
Every day, a [GitHub workflow](.github/workflows/release.yml) compiles the latest
|
|
23
|
+
[IANA tz database](https://data.iana.org/time-zones/tzdb/), takes city populations from
|
|
24
|
+
[GeoNames](https://www.geonames.org/), tests the result and publishes a new version when something
|
|
25
|
+
changed.
|
|
15
26
|
|
|
16
|
-
|
|
27
|
+
Current offsets come from the browser or Node.js at runtime. A site that never updates this package
|
|
28
|
+
still follows daylight saving changes, and agrees with the offsets `Intl.DateTimeFormat` gives the
|
|
29
|
+
rest of the app.
|
|
30
|
+
|
|
31
|
+
## Time zone picker
|
|
17
32
|
|
|
18
33
|
```bash
|
|
19
34
|
npm add @vvo/tzdb
|
|
20
35
|
```
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
```jsx
|
|
38
|
+
import { getTimeZones } from "@vvo/tzdb";
|
|
23
39
|
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
const timeZones = getTimeZones();
|
|
41
|
+
|
|
42
|
+
// Saved values can be any IANA name, like "Asia/Calcutta" or "US/Pacific"
|
|
43
|
+
function findTimeZone(name) {
|
|
44
|
+
return timeZones.find((timeZone) => timeZone.group.includes(name));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function TimeZonePicker({ value, onChange }) {
|
|
48
|
+
const selected = findTimeZone(value ?? Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
49
|
+
return (
|
|
50
|
+
<select value={selected?.name} onChange={(event) => onChange(event.target.value)}>
|
|
51
|
+
{timeZones.map((timeZone) => (
|
|
52
|
+
<option key={timeZone.name} value={timeZone.name}>
|
|
53
|
+
{timeZone.currentTimeFormat}
|
|
54
|
+
</option>
|
|
55
|
+
))}
|
|
56
|
+
</select>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
26
59
|
```
|
|
27
60
|
|
|
28
|
-
|
|
61
|
+
Save `name` in the database: every `Intl` API and date library accepts it.
|
|
29
62
|
|
|
30
|
-
|
|
63
|
+
To search, match the query against the fields people type:
|
|
31
64
|
|
|
32
65
|
```js
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
timeZones.filter((timeZone) =>
|
|
67
|
+
[timeZone.currentTimeFormat, timeZone.countryName, timeZone.abbreviation, ...timeZone.group]
|
|
68
|
+
.join(" ")
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.includes(query.toLowerCase()),
|
|
71
|
+
);
|
|
38
72
|
```
|
|
39
73
|
|
|
40
|
-
|
|
74
|
+
## Country of a visitor
|
|
41
75
|
|
|
42
76
|
```js
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
group: ["America/Los_Angeles"],
|
|
49
|
-
continentCode: "NA",
|
|
50
|
-
continentName: "North America",
|
|
51
|
-
countryName: "United States",
|
|
52
|
-
countryCode: "US",
|
|
53
|
-
mainCities: ["Los Angeles", "San Diego", "San Jose", "San Francisco"],
|
|
54
|
-
rawOffsetInMinutes: -480,
|
|
55
|
-
abbreviation: "PST",
|
|
56
|
-
rawFormat: "-08:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco",
|
|
57
|
-
currentTimeOffsetInMinutes: -420, // "current" time zone offset, this is why getTimeZones() is a method and not just an object: it works at runtime
|
|
58
|
-
currentTimeFormat: "-07:00 Pacific Time - Los Angeles, San Diego",
|
|
59
|
-
},
|
|
60
|
-
// ...
|
|
61
|
-
];
|
|
77
|
+
import { getCountryCode } from "@vvo/tzdb";
|
|
78
|
+
|
|
79
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; // "Europe/Paris"
|
|
80
|
+
getCountryCode(timeZone); // "FR"
|
|
81
|
+
new Intl.DisplayNames(["en"], { type: "region" }).of("FR"); // "France"
|
|
62
82
|
```
|
|
63
83
|
|
|
64
|
-
|
|
84
|
+
It knows every IANA name, including old ones browsers still return, like `Asia/Calcutta`. It weighs
|
|
85
|
+
4 kB and does not load the time zone list.
|
|
86
|
+
|
|
87
|
+
## API
|
|
65
88
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
89
|
+
```js
|
|
90
|
+
import {
|
|
91
|
+
getTimeZones,
|
|
92
|
+
getCountryCode,
|
|
93
|
+
rawTimeZones,
|
|
94
|
+
timeZonesNames,
|
|
95
|
+
abbreviations,
|
|
96
|
+
tzdbVersion,
|
|
97
|
+
} from "@vvo/tzdb";
|
|
98
|
+
```
|
|
71
99
|
|
|
72
|
-
|
|
100
|
+
### getTimeZones(options)
|
|
101
|
+
|
|
102
|
+
Returns time zones sorted by current offset:
|
|
73
103
|
|
|
74
104
|
```js
|
|
75
105
|
{
|
|
76
|
-
name: "America/
|
|
77
|
-
alternativeName: "
|
|
78
|
-
group: ["America/
|
|
106
|
+
name: "America/Los_Angeles",
|
|
107
|
+
alternativeName: "Pacific Time",
|
|
108
|
+
group: ["America/Los_Angeles", "US/Pacific", "PST8PDT"],
|
|
79
109
|
continentCode: "NA",
|
|
80
110
|
continentName: "North America",
|
|
81
|
-
countryName: "
|
|
82
|
-
countryCode: "
|
|
83
|
-
mainCities: ["
|
|
84
|
-
rawOffsetInMinutes: -
|
|
85
|
-
abbreviation: "
|
|
86
|
-
|
|
111
|
+
countryName: "United States",
|
|
112
|
+
countryCode: "US",
|
|
113
|
+
mainCities: ["Los Angeles", "San Diego", "San Jose", "San Francisco"],
|
|
114
|
+
rawOffsetInMinutes: -480,
|
|
115
|
+
abbreviation: "PST",
|
|
116
|
+
dstAbbreviation: "PDT", // only for zones with daylight saving time
|
|
117
|
+
rawFormat: "-08:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco",
|
|
87
118
|
currentTimeOffsetInMinutes: -420,
|
|
88
|
-
currentTimeFormat: "-07:00
|
|
119
|
+
currentTimeFormat: "-07:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco",
|
|
120
|
+
currentAbbreviation: "PDT",
|
|
89
121
|
}
|
|
90
122
|
```
|
|
91
123
|
|
|
92
|
-
|
|
124
|
+
Options:
|
|
93
125
|
|
|
94
|
-
|
|
126
|
+
- `locale`: translates `alternativeName`, `countryName` and `continentName`. With `"fr"`, Los Angeles
|
|
127
|
+
shows as "-07:00 heure du Pacifique nord-américain - Los Angeles, ...". City names stay as they are.
|
|
128
|
+
- `includeUtc`: adds `Etc/UTC`, whose group includes `UTC` and `GMT`.
|
|
129
|
+
- `includeGmtOffsets`: adds the fixed offsets `Etc/GMT-14` to `Etc/GMT+12`. As in POSIX, the sign
|
|
130
|
+
is inverted: `Etc/GMT+5` is 5 hours behind UTC.
|
|
95
131
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// ...
|
|
99
|
-
{
|
|
100
|
-
name: "America/Los_Angeles",
|
|
101
|
-
alternativeName: "Pacific Time",
|
|
102
|
-
group: ["America/Los_Angeles"],
|
|
103
|
-
continentCode: "NA",
|
|
104
|
-
continentName: "North America",
|
|
105
|
-
countryName: "United States",
|
|
106
|
-
countryCode: "US",
|
|
107
|
-
mainCities: ["Los Angeles", "San Diego", "San Jose", "San Francisco"],
|
|
108
|
-
rawOffsetInMinutes: -480,
|
|
109
|
-
abbreviation: "PST",
|
|
110
|
-
rawFormat: "-08:00 Pacific Time - Los Angeles, San Diego, San Jose, San Francisco",
|
|
111
|
-
},
|
|
112
|
-
// ...
|
|
113
|
-
];
|
|
114
|
-
```
|
|
132
|
+
Zones the browser does not know yet are left out, since `Intl` could not format dates in them.
|
|
133
|
+
Runtimes without `Intl` time zone support get every zone at its standard offset.
|
|
115
134
|
|
|
116
|
-
###
|
|
135
|
+
### getCountryCode(timeZone)
|
|
117
136
|
|
|
118
|
-
|
|
137
|
+
The [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of an IANA time zone
|
|
138
|
+
name, or `undefined` for names without a country like `UTC`.
|
|
119
139
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"America/La_Paz",
|
|
128
|
-
"America/Lima",
|
|
129
|
-
"America/Los_Angeles",
|
|
130
|
-
"America/Lower_Princes",
|
|
131
|
-
"America/Maceio",
|
|
132
|
-
"America/Managua",
|
|
133
|
-
"America/Manaus",
|
|
134
|
-
"America/Marigot",
|
|
135
|
-
"America/Martinique",
|
|
136
|
-
"America/Matamoros",
|
|
137
|
-
// ...
|
|
138
|
-
];
|
|
139
|
-
```
|
|
140
|
+
### rawTimeZones
|
|
141
|
+
|
|
142
|
+
The same list without the `current*` fields, sorted by standard offset.
|
|
143
|
+
|
|
144
|
+
### timeZonesNames
|
|
145
|
+
|
|
146
|
+
Every IANA time zone name from [zone.tab](https://data.iana.org/time-zones/tzdb/zone.tab).
|
|
140
147
|
|
|
141
148
|
### abbreviations
|
|
142
149
|
|
|
143
|
-
|
|
150
|
+
Long names mapped to abbreviations, like `"Central European Summer Time": "CEST"`. Careful, CST
|
|
151
|
+
means Central Standard Time (-06:00), China Standard Time (+08:00) and Cuba Standard Time (-05:00).
|
|
144
152
|
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
// ...
|
|
148
|
-
"Australian Central Daylight Time": "ACDT",
|
|
149
|
-
"Australian Central Standard Time": "ACST",
|
|
150
|
-
"Australian Central Time": "ACT",
|
|
151
|
-
"Australian Central Western Standard Time": "ACWST",
|
|
152
|
-
"Australian Eastern Daylight Time": "AEDT",
|
|
153
|
-
"Australian Eastern Standard Time": "AEST",
|
|
154
|
-
"Australian Eastern Time": "AET",
|
|
155
|
-
"Australian Western Daylight Time": "AWDT",
|
|
156
|
-
"Australian Western Standard Time": "AWST",
|
|
157
|
-
"Azerbaijan Summer Time": "AZST",
|
|
158
|
-
"Azerbaijan Time": "AZT",
|
|
159
|
-
"Azores Summer Time": "AZOST",
|
|
160
|
-
"Azores Time": "AZOT",
|
|
161
|
-
"Bangladesh Standard Time": "BST",
|
|
162
|
-
"Bhutan Time": "BTT",
|
|
163
|
-
"Bolivia Time": "BOT",
|
|
164
|
-
// ...
|
|
165
|
-
};
|
|
166
|
-
```
|
|
153
|
+
### tzdbVersion
|
|
167
154
|
|
|
168
|
-
|
|
155
|
+
The IANA tz database release behind the data, like `"2026e"`.
|
|
169
156
|
|
|
170
|
-
##
|
|
157
|
+
## Compared to countries-and-timezones
|
|
171
158
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
159
|
+
| | @vvo/tzdb | countries-and-timezones |
|
|
160
|
+
| ---------------------------------- | ---------------------------- | ----------------------------------- |
|
|
161
|
+
| Data updates | Every day, automatically | By hand |
|
|
162
|
+
| Current offsets | From the browser, at runtime | Computed when the package was built |
|
|
163
|
+
| Grouped list with cities and names | Yes | No |
|
|
164
|
+
| Abbreviations that follow DST | Yes | No |
|
|
165
|
+
| Translations | Any language the browser has | No |
|
|
166
|
+
| Country of a time zone | 4 kB | 9 kB |
|
|
167
|
+
| Everything | 17 kB | 9 kB |
|
|
177
168
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
Sizes are minified and gzipped.
|
|
170
|
+
|
|
171
|
+
## How time zones are grouped
|
|
172
|
+
|
|
173
|
+
Zones share an entry when they are in the same country and their clocks show the same time for the
|
|
174
|
+
next two years. Detroit and New York had different rules a century ago, so IANA keeps both, but
|
|
175
|
+
they share an entry today.
|
|
176
|
+
|
|
177
|
+
`alternativeName` is the English name from [CLDR](https://cldr.unicode.org/) without "Standard",
|
|
178
|
+
"Daylight" or "Summer". When summer and winter names differ, like "Greenwich Mean Time" and "British
|
|
179
|
+
Summer Time", it is CLDR's generic name, "United Kingdom Time". Several countries share names like
|
|
180
|
+
"Eastern Time", so show `countryName` or `mainCities` next to it.
|
|
181
|
+
|
|
182
|
+
Abbreviations come from IANA. When IANA has none, like "+03", they come from `abbreviations` or
|
|
183
|
+
read "GMT+3".
|
package/abbreviations.json
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"Bravo Time Zone": "B",
|
|
45
45
|
"British Summer Time": "BST",
|
|
46
46
|
"Brunei Darussalam Time": "BNT",
|
|
47
|
+
"Brunei Time": "BNT",
|
|
47
48
|
"Cape Verde Time": "CVT",
|
|
48
49
|
"Casey Time": "CAST",
|
|
49
50
|
"Cayman Islands Daylight Saving Time": "CIDST",
|
|
@@ -58,8 +59,10 @@
|
|
|
58
59
|
"Central Time": "CT",
|
|
59
60
|
"Chamorro Standard Time": "ChST",
|
|
60
61
|
"Charlie Time Zone": "C",
|
|
62
|
+
"Chatham Daylight Time": "CHADT",
|
|
61
63
|
"Chatham Island Daylight Time": "CHADT",
|
|
62
64
|
"Chatham Island Standard Time": "CHAST",
|
|
65
|
+
"Chatham Standard Time": "CHAST",
|
|
63
66
|
"Chatham Time": "CHAST",
|
|
64
67
|
"Chile Standard Time": "CLT",
|
|
65
68
|
"Chile Summer Time": "CLST",
|
|
@@ -77,6 +80,7 @@
|
|
|
77
80
|
"Cuba Standard Time": "CST",
|
|
78
81
|
"Davis Time": "DAVT",
|
|
79
82
|
"Delta Time Zone": "D",
|
|
83
|
+
"Dumont d’Urville Time": "DDUT",
|
|
80
84
|
"Dumont-d'Urville Time": "DDUT",
|
|
81
85
|
"Dumont-d’Urville Time": "DDUT",
|
|
82
86
|
"East Africa Time": "EAT",
|
|
@@ -113,6 +117,8 @@
|
|
|
113
117
|
"Gilbert Island Time": "GILT",
|
|
114
118
|
"Gilbert Islands Time": "GILT",
|
|
115
119
|
"Golf Time Zone": "G",
|
|
120
|
+
"Greenland Standard Time": "WGT",
|
|
121
|
+
"Greenland Summer Time": "WGST",
|
|
116
122
|
"Greenwich Mean Time": "GMT",
|
|
117
123
|
"Gulf Standard Time": "GST",
|
|
118
124
|
"Guyana Time": "GYT",
|
|
@@ -138,6 +144,8 @@
|
|
|
138
144
|
"Japan Standard Time": "JST",
|
|
139
145
|
"Kamchatka Summer Time": "PETST",
|
|
140
146
|
"Kamchatka Time": "PETT",
|
|
147
|
+
"Khovd Standard Time": "HOVT",
|
|
148
|
+
"Khovd Summer Time": "HOVST",
|
|
141
149
|
"Kilo Time Zone": "K",
|
|
142
150
|
"Korea Standard Time": "KST",
|
|
143
151
|
"Korean Time": "KST",
|
|
@@ -174,6 +182,8 @@
|
|
|
174
182
|
"Newfoundland Standard Time": "NST",
|
|
175
183
|
"Niue Time": "NUT",
|
|
176
184
|
"Norfolk Daylight Time": "NFDT",
|
|
185
|
+
"Norfolk Island Daylight Time": "NFDT",
|
|
186
|
+
"Norfolk Island Standard Time": "NFT",
|
|
177
187
|
"Norfolk Island Time": "NFT",
|
|
178
188
|
"Norfolk Time": "NFT",
|
|
179
189
|
"November Time Zone": "N",
|
|
@@ -218,6 +228,8 @@
|
|
|
218
228
|
"South Africa Standard Time": "SAST",
|
|
219
229
|
"South Georgia Time": "GST",
|
|
220
230
|
"Srednekolymsk Time": "SRET",
|
|
231
|
+
"St. Pierre & Miquelon Daylight Time": "PMDT",
|
|
232
|
+
"St. Pierre & Miquelon Standard Time": "PMST",
|
|
221
233
|
"St. Pierre & Miquelon Time": "PM",
|
|
222
234
|
"Suriname Time": "SRT",
|
|
223
235
|
"Syowa Time": "SYOT",
|
|
@@ -225,12 +237,15 @@
|
|
|
225
237
|
"Taipei Time": "TWT",
|
|
226
238
|
"Tajikistan Time": "TJT",
|
|
227
239
|
"Tango Time Zone": "T",
|
|
240
|
+
"Timor-Leste Time": "TLT",
|
|
228
241
|
"Tokelau Time": "TKT",
|
|
229
242
|
"Tonga Summer Time": "TOST",
|
|
230
243
|
"Tonga Time": "TOT",
|
|
231
244
|
"Turkey Time": "TRT",
|
|
232
245
|
"Turkmenistan Time": "TMT",
|
|
233
246
|
"Tuvalu Time": "TVT",
|
|
247
|
+
"Türkiye Standard Time": "TRT",
|
|
248
|
+
"Türkiye Time": "TRT",
|
|
234
249
|
"Ulaanbaatar Summer Time": "ULAST",
|
|
235
250
|
"Ulaanbaatar Time": "ULAT",
|
|
236
251
|
"Uniform Time Zone": "U",
|