# `PhoenixLiveCalendar.Availability`
[🔗](https://github.com/mdon/phoenix_live_calendar/blob/v0.5.0/lib/phoenix_live_calendar/availability.ex#L1)

Represents a recurring availability window or a date-specific override.

Used to define when time slots are bookable (business hours, working hours,
provider availability, etc.).

## Recurring availability (day-of-week based)

    # Monday through Friday, 9am to 5pm
    %PhoenixLiveCalendar.Availability{
      days_of_week: [1, 2, 3, 4, 5],
      start_time: ~T[09:00:00],
      end_time: ~T[17:00:00]
    }

## Date-specific override

    # Special hours on a specific date
    %PhoenixLiveCalendar.Availability{
      date: ~D[2026-04-15],
      start_time: ~T[10:00:00],
      end_time: ~T[14:00:00]
    }

    # Block out a specific date entirely
    %PhoenixLiveCalendar.Availability{
      date: ~D[2026-04-20],
      start_time: ~T[00:00:00],
      end_time: ~T[23:59:59],
      available: false
    }

## Per-resource availability

    # Dr. Smith is available Mon/Wed/Fri mornings
    %PhoenixLiveCalendar.Availability{
      days_of_week: [1, 3, 5],
      start_time: ~T[08:00:00],
      end_time: ~T[12:00:00],
      resource_id: "dr-smith"
    }

## Day numbering

Days of week use ISO numbering: 1 = Monday, 7 = Sunday.

# `t`

```elixir
@type t() :: %PhoenixLiveCalendar.Availability{
  available: boolean(),
  date: Date.t() | nil,
  days_of_week: [1..7] | nil,
  end_time: Time.t(),
  resource_id: term() | nil,
  start_time: Time.t()
}
```

# `applies_on?`

```elixir
@spec applies_on?(t(), Date.t()) :: boolean()
```

Returns whether this availability applies on the given date.

Date-specific overrides match by exact date. Recurring availability
matches by day of week.

# `covers_time?`

```elixir
@spec covers_time?(t(), Time.t()) :: boolean()
```

Returns whether the given time falls within this availability window.

# `windows_for_date`

```elixir
@spec windows_for_date([t()], Date.t(), term() | nil) :: [t()]
```

Returns the effective availability windows for a given date from a list of availabilities.

Date-specific overrides take precedence over recurring day-of-week patterns.
Returns only the windows that apply, sorted by start time.

---

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