#timezone #iana #dst #json #tzfiles

tzparse

This high-level library reads IANA system timezone information files and returns transition times (ie. daylight saving time) and human readable data about a timezone.

18 releases (8 stable)

1.1.3 Nov 27, 2020
1.1.1 Jul 3, 2020
1.0.3 Jan 25, 2020
0.5.2 Jan 4, 2020
0.3.0 Nov 20, 2019

#77 in Date and time

Download history 19/week @ 2021-02-20 2/week @ 2021-02-27 10/week @ 2021-03-06 2/week @ 2021-03-13 50/week @ 2021-03-20 36/week @ 2021-03-27 36/week @ 2021-04-03 20/week @ 2021-04-10 61/week @ 2021-04-17 2/week @ 2021-04-24 20/week @ 2021-05-01 2/week @ 2021-05-08 18/week @ 2021-05-15 1/week @ 2021-05-29 18/week @ 2021-06-05

112 downloads per month

GPL-3.0 license

17KB
266 lines

tzparse

Current Crates.io Version Downloads badge

PLEASE NOTE This library is no longer maintained and has been merged with the libtzfile library.

This library's functions are used to retrieve transition times and date/time characteristics for a given TZ. Based on IANA database, system timezone files and libtzfile library that you should use instead.

There are two functions:

get_zoneinfo parses the tzfile and returns a Tzinfo struct which provides useful and human-readable data about the timezone and can be converted to a json string with an optional feature.

get_timechanges obtains time changes for specified year, or all time changes recorded in the TZfile if no year is specified.

Example with get_zoneinfo:

[dependencies]
tzparse = { version = "1.1", features=["json"] }
fn main() {
    println!("{}", tzparse::get_zoneinfo("/usr/share/zoneinfo/Europe/Paris").unwrap().to_json().unwrap());
}

Outputs:

{"timezone":"Europe/Paris","utc_datetime":"2020-01-22T14:12:36.792898Z","datetime":"2020-01-22T15:12:36.792898+01:00",
"dst_from":"2020-03-29T01:00:00Z","dst_until":"2020-10-25T01:00:00Z","dst_period":false,"raw_offset":3600,
"dst_offset":7200,"utc_offset":"+01:00","abbreviation":"CET","week_number":4}

The get_timechanges function for Europe/Paris in 2019 returns:

[Timechange { time: 2019-03-31T01:00:00Z, gmtoff: 7200, isdst: true, abbreviation: "CEST" },
Timechange { time: 2019-10-27T01:00:00Z, gmtoff: 3600, isdst: false, abbreviation: "CET" }]

License: GPL-3.0

Dependencies

~0.8–1.3MB
~22K SLoC