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.
- Leap
Second - A leap-second record.
- PosixTz
- A parsed POSIX-style
TZstring, e.g.EST5EDT,M3.2.0,M11.1.0. - Range
Iter - Iterator returned by
Zone::transitions_for_range. - Range
Transition - A transition produced by
Zone::transitions_for_range. - Transition
- A moment when the timezone rule changes.
- Transition
Rule - 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.
- Zone
Meta - Metadata about a timezone: associated countries and principal coordinates.
- Zone
Type - Describes a local time type (e.g.
EST,EDT).
Enums§
- Error
- Errors produced when loading or parsing timezone data.
- Rule
Kind - Identifies the type of transition rule in a POSIX TZ string.
Functions§
- load
- Loads a
Zoneby IANA timezone name from the embedded database. - load_
insensitive - Loads a
Zoneby name, falling back to case-insensitive matching. - meta
- Returns metadata for the timezone named
name, orNoneif unavailable. - names
- Returns an iterator over every IANA timezone name in the embedded database.
- parse_
iso6709 - Parses coordinates in ISO 6709 format
±DDMM±DDDMMor±DDMMSS±DDDMMSS. - parse_
posix_ tz - Parses a POSIX-style
TZstring.