Event management: fields, sorting, and availability.

Events come in two types:

  • Standard — fixed capacity with optional date
  • Daily — date-based booking with holiday exclusions

Functions

f
addDays(
dateStr: string,
days: number
): string

Add days to a YYYY-MM-DD date string

f
eventDateToCalendarDate(utcIso: string): string | null

Convert a UTC ISO datetime to a YYYY-MM-DD calendar date in the given timezone. Returns null if the input is empty or invalid. Used by the calendar view to map standard event dates to calendar days.

f
formatDateLabel(dateStr: string): string

Format a YYYY-MM-DD date for display. Returns "Monday 15 March 2026"

f
formatDatetimeLabel(iso: string): string

Format an ISO datetime string for display in the given timezone. Returns e.g. "Monday 15 June 2026 at 14:00 BST"

f
getAvailableDates(
event: Event,
holidays: Holiday[]
): string[]

Compute available booking dates for a daily event. Filters by bookable days of the week and excludes holidays. Returns sorted array of YYYY-MM-DD strings.

f
getNextBookableDate(
event: Event,
holidays: Holiday[]
): string | null

Get the next available booking date for a daily event. More efficient than getAvailableDates()[0] — stops at first match. Returns null if no bookable dates are available.

f
mergeEventFields(fieldSettings: EventFields[]): EventFields

Determine which contact fields to collect for multiple events. Returns the union of all field settings, sorted by canonical CONTACT_FIELDS order.

f
normalizeDatetime(
value: string,
label: string
): string

Normalize datetime-local "YYYY-MM-DDTHH:MM" to full UTC ISO string. The input is interpreted as local time in the given timezone and converted to UTC.

f
parseEventFields(fields: EventFields): ContactField[]

Parse a comma-separated fields string into individual ContactField names

f
sortEvents<T extends Event>(
events: T[],
holidays: Holiday[]
): T[]

Sort events in unified 3-tier order. Works with any Event subtype (Event, EventWithCount, etc.).

f
startOfHour(date: Date): Date

Round a date down to the start of the current hour for cache-stable signatures

f
withRequiredEmail(fields: EventFields): EventFields

Ensure "email" is included in an event fields setting

Interfaces

Variables