#timezone #zone #abbreviation #information #translate #time #offset

timezone-abbreviations

Translate timezone abbreviations into timezone information

1 unstable release

0.1.0 Sep 29, 2021

#17 in #abbreviation

MIT license

32KB
369 lines

timezone-abbreviations

This crate allows converting between timezone abbreviations to timezone information.

Note that timezone abbreviations are not standardized:

Keep in mind that time zone abbreviations are not standardized (Hawaii uses both HST or HAST), nor are they unique (CST could belong to US Central Standard Time, Cuba Standard Time, or China Standard TIme), nor do all time zones have abbreviations (many zones in the tzdb zones will just show abbreviations as offsets like "+02"). Also some languages use different abbreviations than we might use in English - example EST in English or HNE in French are both used in Canada for the same zone Matt Johnson-Pint

The data in this crate is based on these two articles:

The way it works is that the content of this page with some manual additions and fixes from Wikipedia were manually downloaded into content.txt. Then, generate.py is used to generate src/generated.rs which contains a static hashmap of all the abbreviations.

This crate uses PHF for a very fast compile-time checked hashmap.

As a convenience, you can just call:

let abbr = timezone_abbreviations::timezone("GMT")

Dependencies

~2MB
~45K SLoC