Expand description
tzdb — Time Zone Database
Static time zone information for tz-rs.
This crate provides all time zones found in the Time Zone Database, currently in the version 2023d (released 2023-12-22).
See the documentation for a full list the the contained time zones: https://docs.rs/tzdb/latest/tzdb/time_zone/index.html
Usage examples
// get the system time zone
let time_zone = tzdb::local_tz().unwrap(); // tz::TimeZoneRef<'_>
let current_time = tzdb::now::local().unwrap(); // tz::DateTime
// access by identifier
let time_zone = tzdb::time_zone::europe::KYIV;
let current_time = tzdb::now::in_tz(tzdb::time_zone::europe::KYIV).unwrap();
// access by name
let time_zone = tzdb::tz_by_name("Europe/Berlin").unwrap();
let current_time = tzdb::now::in_named("Europe/Berlin").unwrap();
// names are case insensitive
let time_zone = tzdb::tz_by_name("ArCtIc/LongYeArByEn").unwrap();
let current_time = tzdb::now::in_named("ArCtIc/LongYeArByEn").unwrap();
// provide a default time zone
let current_time = tzdb::now::local_or(tzdb::time_zone::GMT).unwrap();
let current_time = tzdb::now::in_named_or(tzdb::time_zone::GMT, "Some/City").unwrap();Feature flags
fallback(enabled by default) — compile for unknown target platforms, too
Modules
- Changes between the versions
- Get the current time in some time zone
- All defined time zones statically accessible
Constants
- A list of all known time zones
- The version of the source Time Zone Database
- The SHA512 hash of the source Time Zone Database (using the “Complete Distribution”)
Functions
- Find the time zone of the current system
- Find the raw, unparsed time zone data by name, e.g.
"Europe/Berlin"(case-insensitive) - Find a time zone by name, e.g.
"Europe/Berlin"(case-insensitive)