#date #time #timezone #zone #calendar

tzdb

Static time zone information for tz-rs

61 releases

new 0.5.6 Mar 24, 2023
0.5.3 Jan 1, 2023
0.5.2 Dec 22, 2022
0.5.1 Nov 30, 2022
0.2.1 Mar 27, 2022

#32 in Date and time

Download history 6745/week @ 2022-12-03 5472/week @ 2022-12-10 4525/week @ 2022-12-17 2379/week @ 2022-12-24 4076/week @ 2022-12-31 7280/week @ 2023-01-07 5732/week @ 2023-01-14 5052/week @ 2023-01-21 7699/week @ 2023-01-28 4677/week @ 2023-02-04 5469/week @ 2023-02-11 6108/week @ 2023-02-18 6932/week @ 2023-02-25 7786/week @ 2023-03-04 9069/week @ 2023-03-11 6119/week @ 2023-03-18

30,768 downloads per month
Used in 11 crates (3 directly)

Apache-2.0

2.5MB
50K SLoC

tzdb — Time Zone Database

GitHub Workflow Status Crates.io 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, currently in the version 2023b (released 2023-03-23).

See the documentation for a full list the the contained time zones: https://docs.rs/tzdb/latest/tzdb/time_zone/index.html

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

  • fallback (enabled by default) — compile for unknown target platforms, too

Dependencies

~0.2–26MB
~417K SLoC