ExBooking.ICalendar (ExBooking v0.1.0)

View Source

iCalendar free/busy normalization.

ExBooking.ICalendar extracts FREEBUSY periods from caller-supplied ICS text and returns merged UTC busy intervals. It intentionally does not fetch calendars, understand provider auth, or implement a full calendar sync adapter.

Example

iex> ics = "FREEBUSY:20260713T090000Z/20260713T093000Z"
...> {:ok, [busy]} = ExBooking.ICalendar.free_busy(ics)
...> {busy.kind, busy.start_at, busy.end_at}
{:busy, ~U[2026-07-13 09:00:00Z], ~U[2026-07-13 09:30:00Z]}

Summary

Types

Raw iCalendar text.

Functions

Extracts FREEBUSY periods from iCalendar text.

Types

ics()

@type ics() :: String.t()

Raw iCalendar text.

Functions

free_busy(ics)

@spec free_busy(ics()) :: {:ok, [ExBooking.Interval.t()]} | {:error, term()}

Extracts FREEBUSY periods from iCalendar text.

Supports comma-separated period values in either start/end or start/duration form. Date-times must be UTC (YYYYMMDDTHHMMSSZ). Periods marked FBTYPE=FREE are validated and excluded from the busy result.

Example

iex> {:ok, [busy]} =
...>   ExBooking.ICalendar.free_busy("FREEBUSY:20260713T090000Z/20260713T093000Z")
...>
...> busy.kind
:busy