Territory resolution — the bridge between the CLDR/BCP 47
territory world (:US, :SA, :GB) and Tempo's
locale-dependent constructors (Tempo.workdays/1,
Tempo.weekend/1, and future holiday helpers).
A territory is CLDR's key for locale-dependent data —
weekday arithmetic, first-day-of-week, weekend definition,
public holidays. Tempo.Territory.resolve/1 normalises any
of the following into a canonical uppercase atom:
An atom territory like
:US,:sa,:"sazzzz".A string territory like
"US","sa","sazzzz".A locale string like
"en-US","ar-SA".A
%Localize.LanguageTag{}value.nil— falls back toApplication.get_env(:ex_tempo, :default_territory), then toLocalize.get_locale() |> Localize.Territory.territory_from_locale/1.
Territory resolution is deliberately explicit. It is not
woven into Tempo.select/2 — the selector is pure. Callers
that want locale-aware weekend/workday sets compose them in:
Tempo.select(~o"2026-06", Tempo.workdays(:US))Examples
iex> Tempo.Territory.resolve(:US)
{:ok, :US}
iex> Tempo.Territory.resolve("sazzzz")
{:ok, :SA}
iex> Tempo.Territory.resolve("en-GB")
{:ok, :GB}
Summary
Functions
Normalise value to a canonical territory atom.
Types
@type input() :: atom() | String.t() | Localize.LanguageTag.t() | nil
Functions
Normalise value to a canonical territory atom.
Arguments
valueis one of the input shapes listed in the moduledoc.
Returns
{:ok, territory_atom}on success.{:error, reason}when a locale cannot be validated or a territory cannot be derived.
Examples
iex> Tempo.Territory.resolve(:AU)
{:ok, :AU}
iex> Tempo.Territory.resolve("ar-SA")
{:ok, :SA}