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
Compute how many days ago an event started, relative to today in the configured timezone. Returns null if the event date is today or in the future, or if the date is empty/invalid. For past events, returns a positive integer (1 = yesterday).
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"
Compact ISO datetime formatter for table cells. Returns e.g. "07/04/2026 14:00" in the configured timezone.
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.
Load all events with holidays and return them sorted, filtered by predicate.
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.).
Round a date down to the start of the current hour for cache-stable signatures
Ensure "email" is included in an event fields setting
| "Monday"
| "Tuesday"
| "Wednesday"
| "Thursday"
| "Friday"
| "Saturday"
Day name lookup from Date.getUTCDay() index (Sunday=0)
Usage
import * as mod from "docs/events.ts";