This crate is part of the Rust Zmanim Project.
Embedded Tz
A no_std chrono::TimeZone implementation for TZif data, aimed at embedded deployments. Forked from the tzfile crate with added support for embedded environments and over-the-wire timezone updates.
When to Use This Crate
Use this crate when all of the following are true:
- You run in an embedded /
no_stdenvironment. - You need to deliver time zone database updates over the wire.
- You cannot (or do not want to) rely on full firmware OTA flows from your chip vendor or platform provider.
Most users should not use this crate directly. If you can do normal application or firmware updates, it is usually simpler to use chrono-tz, rebuild with the latest tzdb, and ship via your standard deployment path.
Installation
Add the dependency and enable bundled-tzdb if you want a compile-time copy of the IANA tz database included in your binary:
[]
= { = "https://github.com/dickermoshe/rust-zmanim-project", = ["bundled-tzdb"] }
Usage
Tz does not implement TimeZone directly because it can be large and expensive to clone. Instead, use one of:
&Tz— zero-cost to clone, bounded by a lifetimeRcTz— reference-counted viaRc, not thread-safeArcTz— atomically reference-counted viaArc, thread-safe
Parse a time zone
From the bundled database (requires bundled-tzdb feature):
use Tz;
let tz = named?;
From raw TZif bytes received over the wire:
use Tz;
let tz = parse?;
From a fixed offset or UTC:
use Tz;
let tz = from;
let tz = from;
Convert times
Use &Tz, RcTz, or ArcTz as a chrono::TimeZone:
use ;
use Tz;
let tz = named?;
let utc = Utc.with_ymd_and_hms.unwrap;
let local = utc.with_timezone;
Updating Time Zones Over the Wire
The main reason to use this crate instead of chrono-tz is to push tz database updates to a device without a full firmware update. A typical flow:
- Server side — Build or download a tzdb release. For each zone you need, extract the compiled TZif file (the binary blobs in
/usr/share/zoneinfo). - Validate — Parse every payload with the same
embedded-tzversion running on the device. - Transmit — Send the validated TZif bytes and their IANA identifiers (e.g.
"America/New_York") to the device. - Device side — Call
Tz::parse(name, &bytes)to load each zone.
Use bundled::version() to check which tzdb version is compiled into the binary.
Limitations
- No far-future POSIX tail rules — Unlike
chrono-tz, this crate does not expand the POSIX TZ string appended to TZif files. Offsets past the last explicit transition repeat the final transition's offset indefinitely. For most practical use (within ~10 years of the tzdb release) this is equivalent.
Publishing Policy
This fork is not intended to be published to crates.io. If you want to use it in production, fork the repository and publish under your own ownership.
License
Licensed under MIT. See LICENSE for details.