Event management: fields, sorting, and availability.
Events come in two types:
- Standard — fixed capacity with optional date
- Daily — date-based booking with holiday exclusions
Add days to a YYYY-MM-DD date string
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.
Format a YYYY-MM-DD date for display. Returns "Monday 15 March 2026"
Format an ISO datetime string for display in the given timezone. Returns e.g. "Monday 15 June 2026 at 14:00 BST"
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.
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.
Determine which contact fields to collect for multiple events. Returns the union of all field settings, sorted by canonical CONTACT_FIELDS order.
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.
Parse a comma-separated fields string into individual ContactField names
Sort events in unified 3-tier order. Works with any Event subtype (Event, EventWithCount, etc.).
Day name lookup from Date.getUTCDay() index (Sunday=0)
Usage
import * as mod from "docs/events.ts";