Chrono-TZ

TimeZone implementations for the chrono crate, generated from the IANA time zone database.

Library
Cargo
v0.10.4
279stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
47/100Fair
Development Activity0
Maintenance32
Community76
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture76
Code Quality75
Innovation68
Learning Curve78

Chrono-TZ implements chrono’s TimeZone trait for every zone in the IANA time zone database (tzdata), giving Rust programs access to real-world timezone rules including historical offset changes and daylight saving transitions. The zone table is generated at build time by a build script that parses the bundled IANA tz source files via the companion parse-zoneinfo crate, so the library ships with accurate, up-to-date zone data rather than relying on the host OS’s tzdata installation.

Because it plugs directly into chrono’s existing TimeZone trait, converting between zones, formatting localized timestamps, and comparing datetimes across regions works with the same API surface developers already use for Utc and Local, just parameterized over a specific IANA zone like chrono_tz::America::New_York.

What You Get

  • A Tz enum plus per-zone types (e.g. chrono_tz::Europe::London) covering the full IANA tzdata zone list
  • Correct handling of historical DST rule changes and offset transitions, not just the current UTC offset
  • A FromStr implementation so zone names like “Antarctica/South_Pole” can be parsed at runtime from configuration or user input
  • Optional serde feature for serializing/deserializing timezone values
  • no_std compatibility (with default-features = false) for embedded targets
  • A filter-by-regex build feature to shrink the generated zone table to only the zones an application needs

Common Use Cases

  • Converting user-submitted local timestamps to UTC for storage, and back to the user’s local zone for display
  • Scheduling systems that need to compute “next occurrence” across a DST transition correctly
  • Multi-region applications that display meeting times or logs localized to each user’s IANA timezone
  • Parsing timezone identifiers from config files or APIs into a concrete zone type at runtime

Under The Hood

Architecture - The project is a Cargo workspace with three members: chrono-tz (the public library, whose src/timezone_impl.rs and generated src/prebuilt/ module implement chrono’s TimeZone trait per zone), chrono-tz-build (the build-script logic invoked from chrono-tz’s build.rs to regenerate zone tables), and parse-zoneinfo (a standalone parser for the raw IANA tzdata format bundled under tz/). Tech Stack - Pure Rust, edition 2021, MSRV 1.66, dual-licensed MIT/Apache-2.0; the core crate depends on chrono for its TimeZone/Offset traits and optionally serde for serialization, with zone data generated at build time rather than pulled in as a runtime dependency. Code Quality - src/timezone_impl.rs (398 lines) implements the trait machinery generically over the generated per-zone tables, keeping the hand-written logic small relative to the generated prebuilt module; the crate ships tests/ exercising conversions against known reference offsets, and the workspace’s parse-zoneinfo member is independently versioned and tested since other tools consume it directly. API Design - Because it targets chrono’s existing TimeZone trait, the learning curve is minimal for anyone already using chrono — zone-aware datetimes are constructed and manipulated with the same methods as Utc/Local, and the FromStr impl on Tz makes runtime zone lookup from a string a one-line operation.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search