Skip to main content

Module iana

Module iana 

Source
Expand description

Optional IANA zone name tables.

The tables map IANA identifiers such as Europe/Paris to the POSIX TZ string of the zone. They are generated from the IANA time zone database; the version of the database is in TZDATA_VERSION. One table per region is compiled with its Cargo feature, and the features combine:

FeatureNames
none (default)no names: zone_count is 0 and every lookup fails
iana-africa, iana-america, iana-antarctica, iana-arctic, iana-asia, iana-atlantic, iana-australia, iana-europe, iana-indian, iana-pacificthe names with that prefix, for example Europe/Paris
iana-etcthe fixed offset zones Etc/... and GMT
iana-allevery region

A region holds the names with its prefix only: Atlantic/Madeira is in iana-atlantic, not in iana-europe. The four canonical names without a prefix, CST6CDT, EST5EDT, MST7MDT and PST8PDT, are in iana-america. Factory is in no table.

By default, the tables hold the canonical names and the listed aliases: the backward links that tzdata zone.tab lists for a country, such as Europe/Amsterdam, Europe/Oslo or Atlantic/Reykjavik (zones that tzdata merged into another one), so that every country keeps its names. With iana-legacy-aliases, each enabled region also holds the other backward links, for example US/Eastern, Japan or Asia/Calcutta. An alias is in the region of its prefix, or, without a region prefix, in the region of the zone that it names (US/Eastern is in iana-america). An alias row is its name and the index of the TZ string of the zone that it names, shared with that zone.

zone_name lists the enabled region tables in alphabetical order of feature name (iana-africa through iana-pacific, with iana-etc between iana-australia and iana-europe), with the names of each table sorted, aliases included. Zones of a region that share a TZ string share it in one string blob.

use time_zone::{iana, TimeZone};

let paris = TimeZone::from_iana_name("Europe/Paris").unwrap();
assert_eq!(paris.standard_abbreviation(), "CET");
assert_eq!(
    iana::time_zone_string("Europe/Dublin"),
    Some("IST-1GMT0,M10.5.0,M3.5.0/1")
);
assert!(TimeZone::from_iana_name("Not/AZone").is_none());

Constants§

TZDATA_VERSION
The version of the IANA time zone database that the tables were generated from, for example 2026f.

Functions§

contains
Whether the enabled tables have a zone name.
time_zone_string
The POSIX TZ string of an IANA zone name, if the enabled tables have the name.
zone_count
The number of zone names in the enabled tables.
zone_name
The zone name at an index, for 0 to zone_count.