# `Tempo.Workdays`
[🔗](https://github.com/elixir-tempo/tempo/blob/v2.1.1/lib/tempo/workdays.ex#L1)

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.

# `day_of_week`

```elixir
@type day_of_week() :: 1..7
```

ISO days of the week, Monday 1 to Sunday 7.

# `t`

```elixir
@type t() :: %Tempo.Workdays{
  except: Tempo.t() | nil,
  territory: atom(),
  weekdays: [day_of_week()],
  weekend: [day_of_week()]
}
```

# `new`

```elixir
@spec new(term(), keyword()) :: {:ok, t()} | {:error, Exception.t()}
```

The workdays of a territory, less the days off given.

### Arguments

* `territory` is anything `Tempo.Territory.resolve/1` takes (`:US`,
  `"sa"`, a locale such as `"en-GB"`, or `nil` for the configured
  `:default_territory` and then the current locale's), or a `t:t/0`
  already built.

* `options` is a keyword list of options.

### Options

* `:except` is a `t:Tempo.t/0` with 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 a
  `t:Tempo.t/0`.

### Examples

    iex> {:ok, workdays} = Tempo.Workdays.new(:SA)
    iex> workdays.weekdays
    [1, 2, 3, 4, 7]

# `new!`

```elixir
@spec new!(term(), keyword()) :: t()
```

`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/2` returns 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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
