[][src]Crate tzparse

This library's functions are used to retrieve time changes and date/time characteristics for a given TZ. Based on data provided by system timezone files and low-level parsing library. System TZfiles default location can be overriden with the TZFILES_DIR environment variable.

There are two functions, one using the other's result:

get_timechanges obtains time changes for specified year.

get_zoneinfo further parses the data to provide useful and human-readable output.

Example with get_zoneinfo:

extern crate tzparse;
 
fn main() {
    match tzparse::get_timechanges("Europe/Paris", Some(2019)) {
        Some(tz) => println!("{:?}", tzparse::get_zoneinfo(&tz).unwrap()),
        None => println!("Timezone not found")
    };
}

Outputs:

{ utc_datetime: 2019-09-27T07:04:09.366157Z, datetime: 2019-09-27T09:04:09.366157+02:00,
dst_from: Some(2019-03-31T01:00:00Z), dst_until: Some(2019-10-27T01:00:00Z),
raw_offset: 3600, dst_offset: 7200, utc_offset: +02:00, abbreviation: "CEST" }

The get_timechanges used alone ouputs:

[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" }]

Structs

Timechange

The Timechange struct contains one timechange from the parsed TZfile.

Tzinfo

Convenient and human-readable informations about a timezone.

Functions

get_timechanges

Returns year's (current year is default) timechanges for a timezone. If there's no timechange for selected year, returns the last occured timechange.

get_zoneinfo

Returns convenient data about a timezone. Used for example in my world time API.