#iana #time

iana-time-zone

get the IANA time zone for the current system

20 releases

0.1.19 Sep 27, 2021
0.1.16 Jul 26, 2021
0.1.7 Mar 30, 2021
0.1.2 Oct 9, 2020
0.1.1 Jun 27, 2020

#42 in Date and time

Download history 173/week @ 2021-06-30 127/week @ 2021-07-07 119/week @ 2021-07-14 262/week @ 2021-07-21 145/week @ 2021-07-28 200/week @ 2021-08-04 289/week @ 2021-08-11 176/week @ 2021-08-18 177/week @ 2021-08-25 242/week @ 2021-09-01 385/week @ 2021-09-08 277/week @ 2021-09-15 162/week @ 2021-09-22 322/week @ 2021-09-29 568/week @ 2021-10-06 364/week @ 2021-10-13

884 downloads per month
Used in dtg

MIT/Apache

8KB
86 lines

iana-time-zone - get the IANA time zone for the current system

Crates.io Documentation Crate License build

This small utility crate gets get the IANA time zone for the current system. This is also known the tz database, tzdata, the zoneinfo database and, the Olson database.

Example:

extern crate iana_time_zone;
println!("current: {}", iana_time_zone::get_timezone().unwrap());

You can test this is working on your platform with:

cargo test -- --nocapture

lib.rs:

get the IANA time zone for the current system

This small utility crate provides the get_timezone() function.

# fn main() -> Result<(),anyhow::Error> {
// Get the current time zone as a string.
let tz_str = iana_time_zone::get_timezone()?;
println!("The current time zone is: {}", tz_str);

// Convert the time zone string to a `chrono-tz::Tz` variant.
let tz: chrono_tz::Tz = tz_str.parse().map_err(|e| anyhow::anyhow!("Error: {}", e))?;
println!("The current time zone is: {}", tz);
# Ok(())
# }

Dependencies

~115KB