timezone-data
A #![no_std], allocation-free Rust crate that parses IANA TZif timezone files
and exposes the raw timezone data most libraries keep private: transitions, zone
types, POSIX TZ rules, leap seconds, and per-zone metadata.
Timezone data is compiled from the official IANA source and embedded in the crate as an uncompressed zip archive, so there is no dependency on the host system's timezone files — and no external crate dependencies at all.
This is a Rust port of the Go package gotz.
Highlights
no_std+ noalloc. Everything borrows into the embedded&'staticbytes and decodes lazily through iterators. Nothing is heap-allocated.- Zero dependencies.
- Complete IANA database embedded (600 entries, including the
zone1970.tabandiso3166.tabmetadata tables).
Usage
use load;
let z = load?;
// Inspect zone types (EST, EDT, ...).
for zt in z.types
// Iterate historical transitions.
for t in z.transitions
// Look up the active zone at a specific Unix timestamp.
let zt = z.lookup;
println!;
// Get the POSIX TZ rule for future transitions.
if let Some = z.extend
// Country and coordinates metadata.
if let Some = z.meta
# Ok::
Times are expressed as i64 Unix seconds — the crate is timezone-library
agnostic. If you need a chrono/time value, convert at the boundary;
[Zone::raw_data] also returns the original TZif bytes for feeding into another
parser.
API overview
| Item | Description |
|---|---|
load(name) -> Result<Zone, Error> |
Load a zone by IANA name (""/"UTC" → UTC). |
load_insensitive(name) |
Load with case-insensitive fallback. |
parse(name, data) |
Parse arbitrary TZif bytes. |
names() |
Iterate every embedded entry name. |
Zone::types() / type_at(i) |
Local time types (abbrev, offset, DST flag). |
Zone::transitions() |
Stored transition records. |
Zone::leap_seconds() |
Leap-second records. |
Zone::lookup(unix) |
Zone type in effect at an instant. |
Zone::transitions_for_range(start, end) |
Stored + POSIX-generated transitions in [start, end). |
Zone::extend() / extend_raw() |
Parsed / raw POSIX TZ footer. |
Zone::meta() |
Country + coordinate metadata. |
parse_posix_tz(s) |
Parse a POSIX TZ string directly. |
Updating the embedded data
zoneinfo.zip is committed to the repository. To refresh it from a new IANA
release, compile the tzdata with zic and repackage it with no compression
(STORE) — the embedded reader does not implement inflate. The original gotz
repository's update.sh / mkzip.go produce a compatible archive; copy the
resulting zoneinfo.zip into this crate's root and rebuild.
License
MIT. Timezone data is in the public domain (IANA).