APITime.Zone

Time.Zone

Immutable timezone rules. UTC and fixed offsets are pure; loading a named IANA zone performs IO and caches successful loads for this process. System timezone data takes precedence over the Go toolchain’s embedded fallback. The machine’s zone is available only explicitly through system. Aliases retain their requested name.

import Time.Zone as Zone
import Fail
import Result exposing (Result(..))

Fail.attempt { Zone.fixedOffset (-10800) |> Zone.identifier } == Ok "-03:00"
Fail.attempt { Zone.fixedOffset 0 } == Ok Zone.utc

Zone

type ZoneSource

Shared immutable rules, equal by identifier. Zero fixed offset is UTC.

Instances:

Eq Zone
Show Zone

firstInRange

firstInRange : Int -> Int -> Zone ->{Fail Error} IntSource

The earliest instant whose local reading lies in [start, finish), both encoded as local epoch seconds. A completely skipped interval fails with Nonexistent; bounds outside the calendar fail with OutOfRange. The exclusive finish may be 10000-01-01.

fixedOffset

fixedOffset : Int ->{Fail Error} ZoneSource

A constant offset in seconds, strictly between -86400 and 86400. Fails with InvalidComponent “offset”.

identifier

identifier : Zone -> StringSource

The requested IANA name, UTC, Local, or a canonical numeric fixed offset.

load

load : String ->{IO} Maybe ZoneSource

Looks up an IANA name. Empty names and Local answer Nothing, so the machine’s ambient timezone never enters a value implicitly.

offsetAt

offsetAt : Int -> Zone -> IntSource

Offset in seconds east of UTC at a Unix second. Always strictly within a day: zone data violating that contract is rejected when it is applied.

resolve

resolve : Resolution -> Int -> Zone ->{Fail Error} IntSource

Resolves a local epoch-second reading (calendar fields encoded as UTC) to Unix seconds. Earlier/Later shift backward/forward by the actual gap; Compatible chooses Earlier for overlaps and Later for gaps. Fails with OutOfRange for a reading outside years 1 through 9999, Ambiguous or Nonexistent under Reject, and Nonexistent when the zone has no candidate.

system

system : () ->{IO} ZoneSource

The machine’s zone, detected once per process from the TZ variable or the system zone database link. When no IANA name can be determined the rules still apply but the identifier is “Local”, which load does not accept.

utc

utc : ZoneSource

Universal coordinated time, without offset transitions.