Cldr.Locale.timezone_from_locale
You're seeing just the function
timezone_from_locale
, go back to Cldr.Locale module for more information.
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 byCldr.Locale.new/2
or anylocale_name
returned byCldr.known_locale_names/1
. If the parameter is alocale_name
then a default backend must be configured inconfig.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"}}
Specs
timezone_from_locale(locale_name(), Cldr.backend()) :: String.t() | {:error, {module(), String.t()}}
Returns the effective time zone for a locale.
Arguments
locale_name
is any name returned byCldr.known_locale_names/1
backend
is any module that includesuse Cldr
and therefore is aCldr
backend module
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"}}