`Chrono-TZ` is a library that provides implementors of the TimeZone trait for `rust-chrono`. The impls are generated by a build script using the IANA database and `parse-zoneinfo`.
Questions tagged [chrono-tz]
4 questions
10
votes
2 answers
Getting the current time in specified timezone
Using the Chrono-TZ library, how can I get the current time in a specified time zone?
I tried
let naive_dt = Local::now().naive_local();
let dt = Los_Angeles.from_local_datetime(&naive_dt).unwrap();
println!("{:#?}", dt);
But this printed the…

Synesso
- 37,610
- 35
- 136
- 207
3
votes
1 answer
Is there a way to parse a timezone abbreviation into a timezone offset in Rust?
Is there a way of parsing timezone abbreviations (like EST or MDT) to a timezone offset (e.g. -5 hours or -7 hours) in Rust? The chrono_tz crate almost seems to do this, but not quite.

Ted Middleton
- 6,859
- 10
- 51
- 71
0
votes
1 answer
Define variable of type TimeZone
The following compiles and runs fine:
use chrono_tz::Tz;
use chrono::{TimeZone, NaiveDate};
use arrow2::temporal_conversions::parse_offset;
fn my_func(tz: &str) -> (){
let ndt = NaiveDate::from_ymd_opt(2018, 9, 28).unwrap().and_hms_opt(2, 30,…

ignoring_gravity
- 6,677
- 4
- 32
- 65
-2
votes
2 answers
How to convert a TimeZone enumeration variant into a fixed offset?
I am trying to convert a chrono_tz::Tz timezone offset into a fixed offset in units of number of hours.
This is how I have managed to construct a Tz object:
let input_string_timezone = "Europe/London";
let tz_timezone =…

FreelanceConsultant
- 13,167
- 27
- 115
- 225