zones

Package Version Hex Docs

Prebuilt time zone data for the tzif package.

Current tzdata version: 2026a.

When to use

Generally you should prefer loading time zone information provided by your operating system by using tzif directly. In some cases this may not be preferrable:

In these situations you may opt to download time zone data from IANA, process it with zic, and then load it with tzif. Alternatively, you may use this package which has done that part for you.

The downside of this package is that you have to keep it updated by updating the dependency, and thus releasing a new version of your app. Take this into account when making your decision on which method to use for obtaining time zone information.

Versioning

This package follows modified semantic versioning:

Thus you can always see the tzdata version that the package contains from the first four numbers of the minor version.

Usage

gleam add zones@1
import zones
import tzif/tzcalendar
import tzif/database

pub fn main() -> Nil {
  let now = timestamp.system_time()

  // Load all timezones
  let tzdb = zones.database()

  case tzcalendar.to_time_and_zone(now, "Europe/Helsinki", db) {
    Ok(time_and_zone) -> // See tzif documentation on further usage
    ...
  }

  // Alternatively, construct your own database from only the zones you want
  let tzdb = database.new()
  |> database.add_tzfile("Europe/Helsinki", zones.europe__helsinki)
  |> database.add_tzfile("Indian/Reunion", zones.indian__reunion)
}
Search Document