A territory's workdays less a set of days off: the days a school or a business is open.
Tempo.workdays/2 builds one, and it goes wherever a territory does:
Tempo.select/3 selects its days, and the workday functions
(Tempo.workday?/2, Tempo.next_workday/2, Tempo.previous_workday/2,
Tempo.nearest_workday/2, Tempo.add_workdays/3,
Tempo.roll_to_workday/3, Tempo.count_workdays/2) step over its days
off as well as its weekend. The weekdays and the weekend are the
territory's, from CLDR through Localize.
Summary
Types
@type day_of_week() :: 1..7
ISO days of the week, Monday 1 to Sunday 7.
@type t() :: %Tempo.Workdays{ except: Tempo.t() | nil, territory: atom(), weekdays: [day_of_week()], weekend: [day_of_week()] }
Functions
@spec new(term(), keyword()) :: {:ok, t()} | {:error, Exception.t()}
The workdays of a territory, less the days off given.
Arguments
territoryis anythingTempo.Territory.resolve/1takes (:US,"sa", a locale such as"en-GB", ornilfor the configured:default_territoryand then the current locale's), or at/0already built.optionsis a keyword list of options.
Options
:exceptis aTempo.t/0with spans, the days off: a set of dates, a recurrence, a holiday set.
Returns
{:ok, workdays}.{:error, %ArgumentError{}}for a value that names no territory, an option this function does not take, or days off that are not aTempo.t/0.
Examples
iex> {:ok, workdays} = Tempo.Workdays.new(:SA)
iex> workdays.weekdays
[1, 2, 3, 4, 7]
new/2, returning its answer or raising the error.
Arguments
- The arguments are those of
new/2.
Options
- The options of
new/2.
Returns
- What
new/2returns as{:ok, answer}, the answer alone. The error it returns as{:error, exception}is raised.
Examples
iex> ~o"2026-06-14/2026-06-20" |> Tempo.select!(Tempo.Workdays.new!(:SA)) |> Tempo.IntervalSet.count()
5