73 releases

0.7.2 Sep 15, 2024
0.6.1 Dec 30, 2023
0.5.7 May 11, 2023
0.5.6 Mar 24, 2023
0.2.1 Mar 27, 2022

#59 in Date and time

Download history 38436/week @ 2024-09-20 41147/week @ 2024-09-27 41389/week @ 2024-10-04 43371/week @ 2024-10-11 45320/week @ 2024-10-18 47455/week @ 2024-10-25 48905/week @ 2024-11-01 45149/week @ 2024-11-08 49924/week @ 2024-11-15 46606/week @ 2024-11-22 54382/week @ 2024-11-29 56283/week @ 2024-12-06 52804/week @ 2024-12-13 36117/week @ 2024-12-20 57061/week @ 2024-12-27 45209/week @ 2025-01-03

200,852 downloads per month
Used in 71 crates (8 directly)

Apache-2.0

2MB
39K SLoC

tzdb — Time Zone Database

GitHub Workflow Status Crates.io docs.rs Minimum supported Rust version License: Apache-2.0

Static time zone information for tz-rs.

This crate provides all time zones found in the Time Zone Database.

Usage examples

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")?;

Feature flags

  • local (enabled by default) — enable functions to query the current system time
  • now (enabled by default) — enable functions to query the current system time
  • std (enabled by default, now and local) — enable the use of features in the std crate
  • alloc (enabled by std) — enable the use of features in the alloc crate

Dependencies

~0.2–5MB
~10K SLoC