time
time copied to clipboard
tzdb support
This is a general tracking issue for all support related to the IANA Time Zone database.
At some point in the future, my hope is to have full support for the tzdb via a ZonedDateTime
struct and a Period
type.
General inspiration could come from C++20's proposed API for timezones [ref]. It should be possible to build a static/const singleton by using a build script.
The tzfile
crate was recently brought to my attention and may be a decent starting point once I get around to implementing this.
I've just begun implementing support for tz database without relying on chrono dependency.
EDIT: link to repository for anyone interested: https://github.com/Yuri6037/time-tz
Quick update: I've just finished initial version with support for timezone conversions: https://crates.io/crates/time-tz
Thank you! It's by no means the kind of API that I've envisioned, but having something will hopefully be helpful to others until I get around to this — whenever that may be.
This is not yet finished. I don't plan to leave the API as it is forever. The reason why it's done this way is because parsing the tz info and setting up the actual lookup code was more complicated than I've anticipated.
My plan is to have an API similar to chrono-tz to quickly access the various timezones.
If anyone needs features that are not currently supported by time-tz feel free to open issues on the GitHub.
The reason why it's done this way is because parsing the tz info and setting up the actual lookup code was more complicated than I've anticipated.
That's why this issue is E-hard
🙂 I look forward to seeing what you are able to do.
Just a quick update: I've finally finished API v2 which now allows to very quickly re-implement localtime:
let system_tz = time_tz::system::get_timezone()
.expect("Failed to find system timezone");
let localtime = OffsetDateTime::now_utc().to_timezone(system_tz);
// the system timezone name in IANA format is in system_tz.name() now
Something to keep an eye on/draw inspiration from is https://github.com/unicode-org/icu4x/issues/1003 which is the tracking issue for ZonedDateTime
in icu4x. It draws inspiration from the TC39 Temporal standard which I've personally come to like very much!
Thanks @LinusU! I am aware of temporal, but I'll definitely check out that issue.
@Yuri6037 thank you for the crate dude, it's awesome!