Cldr.Locale.timezone_from_locale

You're seeing just the function timezone_from_locale, go back to Cldr.Locale module for more information.
Link to this function

timezone_from_locale(language_tag)

View Source (since 2.19.0)

Specs

timezone_from_locale(Cldr.LanguageTag.t() | locale_name()) ::
  String.t() | {:error, {module(), String.t()}}

Returns the effective time zone for a locale.

Arguments

  • language_tag is any language tag returned by Cldr.Locale.new/2 or any locale_name returned by Cldr.known_locale_names/1. If the parameter is a locale_name then a default backend must be configured in config.exs or an exception will be raised.

Returns

  • The time zone ID as a String.t or {:error, {exception, reason}}

Examples

iex> Cldr.Locale.timezone_from_locale "en-US-u-tz-ausyd"
"Australia/Sydney"

iex> Cldr.Locale.timezone_from_locale "en-AU"
{:error,
 {Cldr.AmbiguousTimezoneError,
  "Cannot determine the timezone since the territory :AU has 24 timezone IDs"}}
Link to this function

timezone_from_locale(locale, backend)

View Source (since 2.19.0)

Specs

timezone_from_locale(locale_name(), Cldr.backend()) ::
  String.t() | {:error, {module(), String.t()}}

Returns the effective time zone for a locale.

Arguments

Returns

  • The time zone ID as a String.t or {:error, {exception, reason}}

Examples

iex> Cldr.Locale.timezone_from_locale "en-US-u-tz-ausyd", TestBackend.Cldr
"Australia/Sydney"

iex> Cldr.Locale.timezone_from_locale "en-AU", TestBackend.Cldr
{:error,
 {Cldr.AmbiguousTimezoneError,
  "Cannot determine the timezone since the territory :AU has 24 timezone IDs"}}