Expand description
Utility crate to figure out the IANA (Olson) timezone of the current machine. The IANA timezones have been largely established as the standard for identifying timezones but retrieving the current timezone in that format is a surprisingly complex problem. Additionally Windows machines use an incompatible timezone system and this crate helps automaticaly mapping these to the IANA timezones. For this it uses the CLDR maintained timezone mapping.
§Getting Timezones
To retrieve the current timezone call the get_local_zone
function. It will
try different sources to get the current timezone. When the auto_validation
feature is enabled it will attempt to validate each source against the current
chrono_tz
database. Alternatively
get_local_zone_with_validation
can be used an be supplied an alternative
validator function.
If the timezone cannot be found a user of this crate shall assume the system is running in UTC.
§Features
The following optional features exist:
auto_validation
: when enabled timezones encountered are validated withchrono_tz
by default.win_zones
: when enabled functions are exposed to map between windows and IANA timezones.
Functions§
- Returns the local timezone if it can be found.
- Returns the local timezone validating it with a custom function.
- Look up a windows timezone for an IANA zone.
- Given a windows zone name and an optional territory code returns the IANA zone.