@vvo/tzdb 6.199.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 +43 -3
- package/dist/index.cjs +4638 -976
- package/dist/index.d.cts +51 -40
- package/dist/index.d.ts +51 -40
- package/dist/index.js +4632 -953
- package/package.json +75 -45
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
5
|
```js
|
|
6
6
|
import { getTimeZones } from "@vvo/tzdb";
|
|
@@ -14,7 +14,8 @@ getTimeZones().map((timeZone) => timeZone.currentTimeFormat);
|
|
|
14
14
|
- Current offsets and abbreviations: PDT in summer, PST in winter.
|
|
15
15
|
- Every current and deprecated IANA name, so saved values always find their entry.
|
|
16
16
|
- Names in any language the browser supports.
|
|
17
|
-
-
|
|
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.
|
|
18
19
|
|
|
19
20
|
## Always up to date
|
|
20
21
|
|
|
@@ -70,10 +71,30 @@ timeZones.filter((timeZone) =>
|
|
|
70
71
|
);
|
|
71
72
|
```
|
|
72
73
|
|
|
74
|
+
## Country of a visitor
|
|
75
|
+
|
|
76
|
+
```js
|
|
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"
|
|
82
|
+
```
|
|
83
|
+
|
|
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
|
+
|
|
73
87
|
## API
|
|
74
88
|
|
|
75
89
|
```js
|
|
76
|
-
import {
|
|
90
|
+
import {
|
|
91
|
+
getTimeZones,
|
|
92
|
+
getCountryCode,
|
|
93
|
+
rawTimeZones,
|
|
94
|
+
timeZonesNames,
|
|
95
|
+
abbreviations,
|
|
96
|
+
tzdbVersion,
|
|
97
|
+
} from "@vvo/tzdb";
|
|
77
98
|
```
|
|
78
99
|
|
|
79
100
|
### getTimeZones(options)
|
|
@@ -111,6 +132,11 @@ Options:
|
|
|
111
132
|
Zones the browser does not know yet are left out, since `Intl` could not format dates in them.
|
|
112
133
|
Runtimes without `Intl` time zone support get every zone at its standard offset.
|
|
113
134
|
|
|
135
|
+
### getCountryCode(timeZone)
|
|
136
|
+
|
|
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`.
|
|
139
|
+
|
|
114
140
|
### rawTimeZones
|
|
115
141
|
|
|
116
142
|
The same list without the `current*` fields, sorted by standard offset.
|
|
@@ -128,6 +154,20 @@ means Central Standard Time (-06:00), China Standard Time (+08:00) and Cuba Stan
|
|
|
128
154
|
|
|
129
155
|
The IANA tz database release behind the data, like `"2026e"`.
|
|
130
156
|
|
|
157
|
+
## Compared to countries-and-timezones
|
|
158
|
+
|
|
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 |
|
|
168
|
+
|
|
169
|
+
Sizes are minified and gzipped.
|
|
170
|
+
|
|
131
171
|
## How time zones are grouped
|
|
132
172
|
|
|
133
173
|
Zones share an entry when they are in the same country and their clocks show the same time for the
|