Time.Zone

lib/Time/Zone.gob

A time zone: the rules that say what the clocks read at each instant in a place. Either a fixed offset, a POSIX rule, or a table of transitions read from the system's time zone files, followed by a POSIX rule.

A zone is named by its id, America/Toronto, and two zones are equal when their ids are. That is sound because a zone, once read, is never read again: every named lookup of one id in a process gives the same rules.

type Zone
type ZoneError = InvalidName(String) | UnknownZone(String) | Unreadable(String, String) | Malformed(String) | NoSystemZone

Why a zone could not be had: an id with characters or components no zone name has; no file for it; a file that could not be read, or is not a TZif file; or, for the system's zone, nothing that says what it is.

let utc : Zone
fun fixed : fun(Offset) -> Zone

The zone always offset from UTC, named by the offset: +05:30.

fun posix : fun(String) -> Option Zone

The zone a POSIX TZ rule describes, EST5EDT,M3.2.0,M11.1.0, named by the rule's text. Such an id cannot appear in RFC 9557 text, so a DateTime in this zone shows text that DateTime.parse does not read back; it is for rules that come from outside, and for tests that must not depend on the system's files.

fun fromTzif : fun(String, Array Byte) -> Option Zone

The zone in the TZif file bytes, named id.

fun id : fun(Zone) -> String
fun offsetAt : fun(Zone, Instant) -> Offset
fun offsetAtSecond : fun(Zone, UnixSeconds) -> Offset

The offset in force at t, which need not be a second an Instant can hold.

fun transitions : fun(Zone, UnixSeconds, UnixSeconds) -> Array Transition

The transitions from from to to, both included, in order.

fun named : fun(String) -> Either ZoneError Zone

The zone the system's time zone files call id, America/Toronto: read from $TZDIR, or /usr/share/zoneinfo if that is unset, once per process.

fun system : fun() -> Either ZoneError Zone

The zone the system is set to, found once per process: from $TZ if it is set -- a zone name, : and a name, a path to a TZif file, or a POSIX rule -- and otherwise from /etc/localtime, which names its zone by being a symbolic link into the zone files. A copied /etc/localtime has no name of its own, and its zone's id is its path.

instance Error ZoneError
instance Show ZoneError
instance Eq Zone
instance Hash Zone
instance Show Zone