View Source Cldr.Timezone (Cldr v2.35.1)

Functions to map between the CLDR short time zone code and the IANA timezone names.

The Unicode locale extension U allows the specification of the time zone requested for the provided locale.

This short timezone codes never change even if the IANA names change over time. Therefore these short codes are always stable between CLDR releases.

Link to this section Summary

Functions

Returns a :{:ok, list} where list is a list of IANA timezone names for a given CLDR short zone code. If no such short code exists then :error is returned.

Returns a list of IANA time zone names for a given CLDR short zone code, or nil

Returns a mapping of CLDR short zone codes to IANA timezone names.

Returns a mapping of territories to their known IANA timezone names.

Link to this section Functions

@spec fetch(String.t()) :: {:ok, [String.t()]} | :error

Returns a :{:ok, list} where list is a list of IANA timezone names for a given CLDR short zone code. If no such short code exists then :error is returned.

example

Example

iex> Cldr.Timezone.fetch("ausyd")
{:ok,
 ["Australia/Sydney", "Australia/ACT", "Australia/Canberra", "Australia/NSW"]}

iex> Cldr.Timezone.fetch("nope")
:error
Link to this function

get(short_zone, default \\ nil)

View Source
@spec get(String.t(), String.t() | nil) :: [String.t()] | nil

Returns a list of IANA time zone names for a given CLDR short zone code, or nil

examples

Examples

iex> Cldr.Timezone.fetch("ausyd")
["Australia/Sydney", "Australia/ACT", "Australia/Canberra", "Australia/NSW"]}

iex> Cldr.Timezone.fetch("nope")
nil
@spec timezones() :: map()

Returns a mapping of CLDR short zone codes to IANA timezone names.

Link to this function

timezones_for_territory()

View Source
@spec timezones_for_territory() :: map()

Returns a mapping of territories to their known IANA timezone names.