Crate tzdb

source · []
Expand description

tzdb — Time Zone Database

GitHub Workflow Status Crates.io Minimum supported Rust version License

Static time zone information for tz-rs.

This crate provides all time zones found in the Time Zone Database, currently in the version 2022a (released 2022-03-15).

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

Usage examples

use tz::{DateTime, TimeZone};
use tzdb::{time_zone, tz_by_name};

// access by identifier
DateTime::now(time_zone::europe::KIEV);
// access by name
DateTime::now(tz_by_name("Europe/Berlin").unwrap());
// names are case insensitive
DateTime::now(tz_by_name("ArCtIc/LongYeArByEn").unwrap());

Feature flags

  • by-name (enabled by default) — enables tz_by_name() to get a time zone at runtime by name

  • list (enabled by default) — enables TZ_NAMES to get a list of all shipped time zones

  • local (enabled by default) — enables local_tz() to get the system time zone

  • serde-as — enables the module serde_as to (de)serialize (Utc)DateTimes with serde

  • binary – make the unparsed, binary tzdata of a time zone available

Modules

Changes between the versions

serde_asserde-as

Helper functions to be used with serde

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

raw_tz_by_namebinary and (by-name or local)

Find the raw, unparsed time zone data by name, e.g. "Europe/Berlin" (case-insensitive)

tz_by_nameby-name or local

Find a time zone by name, e.g. "Europe/Berlin" (case-insensitive)