Crates.io | tzdb |
lib.rs | tzdb |
version | 0.7.2 |
source | src |
created_at | 2022-02-21 18:47:34.43952 |
updated_at | 2024-09-15 23:36:09.22709 |
description | Static time zone information for tz-rs |
homepage | |
repository | https://github.com/Kijewski/tzdb |
max_upload_size | |
id | 536913 |
size | 35,069 |
Static time zone information for tz-rs.
This crate provides all time zones found in the Time Zone Database.
let time_zone = tzdb::local_tz()?; // tz::TimeZoneRef<'_>
let current_time = tzdb::now::local()?; // 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)?;
// access by name
let time_zone = tzdb::tz_by_name("Europe/Berlin")?;
let current_time = tzdb::now::in_named("Europe/Berlin")?;
// names are case insensitive
let time_zone = tzdb::tz_by_name("ArCtIc/LongYeArByEn")?;
let current_time = tzdb::now::in_named("ArCtIc/LoNgYeArByEn")?;
// provide a default time zone
let current_time = tzdb::now::local_or(tzdb::time_zone::GMT)?;
let current_time = tzdb::now::in_named_or(tzdb::time_zone::GMT, "Some/City")?;
local
(enabled by default) — enable functions to query the current system timenow
(enabled by default) — enable functions to query the current system timestd
(enabled by default, now
and local
) — enable the use of features in the std
cratealloc
(enabled by std
) — enable the use of features in the alloc
crate