Skip to main content

Crate timezone_data

Crate timezone_data 

Source
Expand description

timezone-data provides direct, allocation-free access to IANA timezone data, exposing the transitions, zone types, POSIX TZ rules, leap seconds, and metadata that most timezone libraries keep private.

Timezone data is compiled from the official IANA source and embedded in the crate as pre-parsed static objects — one per zone — so there is no dependency on the host system’s timezone files and nothing is parsed at runtime. The crate is #![no_std] and never allocates: a lookup is a binary search over &'static data.

§Example

let z = timezone_data::load("America/New_York").unwrap();

// Inspect zone types (EST, EDT, ...).
for zt in z.types() {
    // zt.abbrev, zt.offset, zt.is_dst
    let _ = zt;
}

// Look up the active zone at a specific Unix timestamp.
let zt = z.lookup(1_700_000_000);
assert_eq!(zt.abbrev, "EST");

// Compute future transitions from the POSIX TZ rule.
if let Some(rule) = z.extend() {
    let (start, end) = rule.transitions_for_year(2025).unwrap();
    assert!(start < end);
}

Structs§

Country
An ISO 3166 country associated with a timezone.
LeapSecond
A leap-second record.
PosixTz
A parsed POSIX-style TZ string, e.g. EST5EDT,M3.2.0,M11.1.0.
RangeIter
Iterator returned by Zone::transitions_for_range.
RangeTransition
A transition produced by Zone::transitions_for_range.
Transition
A moment when the timezone rule changes.
TransitionRule
Specifies when a DST transition occurs within a year.
Zone
A parsed IANA timezone, exposing transitions, zone types, leap seconds, and the POSIX TZ extend rule.
ZoneMeta
Metadata about a timezone: associated countries and principal coordinates.
ZoneType
Describes a local time type (e.g. EST, EDT).

Enums§

Error
Errors produced when loading or parsing timezone data.
RuleKind
Identifies the type of transition rule in a POSIX TZ string.

Functions§

load
Loads a Zone by IANA timezone name from the embedded database.
load_insensitive
Loads a Zone by name, falling back to case-insensitive matching.
meta
Returns metadata for the timezone named name, or None if unavailable.
names
Returns an iterator over every IANA timezone name in the embedded database.
parse_iso6709
Parses coordinates in ISO 6709 format ±DDMM±DDDMM or ±DDMMSS±DDDMMSS.
parse_posix_tz
Parses a POSIX-style TZ string.