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 = Tz::from_str(input_string_timezone)
.expect("failed to convert string to chrono tz");
From this I am able to get the name of the offset, as well as the offset in units of seconds, for when daylight savings is in effect and not in effect. This is how I did that:
println!("tz_offset: {}", tz_offset);
println!("tz_offset base_utc_offset: {}", tz_offset.base_utc_offset());
println!("tz_offset dst_offset: {}", tz_offset.dst_offset());
I have managed to convert the timezone object into an offset in terms of the number of seconds from UTC. However, what I have produced is two possible values of the offset, rather than the current value of the offset, today.
What I wish to do is obtain "todays" offset. In order to do this I would have to supply todays date, to some trait or function, but I don't know if the Rust chrono
or chrono_tz
crates have support for this operation.