Tempo.Territory (Tempo v2.1.1)

Copy Markdown View Source

Which territory a caller means: the CLDR territory (:US, :SA, :GB) whose weekend, workdays and conventions Tempo asks Localize for.

A territory may be named directly, taken from a locale, or left to the application: nil is the configured :default_territory, and failing that the territory of the current locale.

config :ex_tempo, default_territory: :AU

Summary

Functions

The territory a value names.

Functions

resolve(tag)

@spec resolve(atom() | String.t() | Localize.LanguageTag.t() | nil) ::
  {:ok, atom()} | {:error, Exception.t()}

The territory a value names.

Arguments

  • value is a territory as an atom or a string (:US, "sa"), a locale ("en-GB", a Localize.LanguageTag.t/0) whose territory is taken, or nil for the application's :default_territory and then the current locale's.

Returns

  • {:ok, territory}, an atom.

  • {:error, %ArgumentError{}} for a value that names none.

Examples

iex> Tempo.Territory.resolve(:US)
{:ok, :US}

iex> Tempo.Territory.resolve("sa")
{:ok, :SA}

iex> Tempo.Territory.resolve("en-GB")
{:ok, :GB}

iex> {:error, %ArgumentError{}} = Tempo.Territory.resolve("nowhere at all")