Listing management: fields, sorting, and availability.

Listings come in two types:

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

Functions

f
addDays

Add days to a real-calendar-day date. The caller's boundary brands the value, so a skip-the-parser caller cannot type-check.

f
addMonthsIso

Add N months to an ISO timestamp, clamping to the last day of the target month. e.g. 2026-01-31 + 1mo → 2026-02-28 Preserves the time component (hour/minute/second/ms). Zero months returns the input with canonical ISO string formatting.

f
bookedSpanDays

The whole day count of a stored [start_at, end_at) booking range — the customisable day count the buyer chose. A missing or degenerate range is 1.

f
coveredDays
No documentation available
f
dateRange

Generate a range of YYYY-MM-DD date strings from start to end (inclusive). A start past the end is an empty range: Array.from reads the negative length as zero.

f
daysAgo

Compute how many days ago an listing started, relative to today in the configured timezone. Returns null if the listing date is today or in the future, or if the date is empty/invalid. For past listings, returns a positive integer (1 = yesterday).

f
formatDatetimeLabel

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

f
formatDatetimeShort

Compact ISO datetime formatter for table cells. Returns e.g. "07/04/2026 14:00" in the configured timezone.

f
formatTimeAgo

Human "time ago" label for a past ISO timestamp, relative to nowMsValue (epoch ms), via Intl.RelativeTimeFormat in the largest whole unit that applies — e.g. "now", "5 minutes ago", "yesterday", "2 days ago". Returns null for an unparseable or future timestamp.

f
getAvailableDates

A duration_days > 1 listing excludes a start date whose full range hits a non-bookable day or runs past the booking window.

f
getBookableStartDates

Available start dates for a daily listing's booking/date pickers. Customisable-days listings use single-day availability: the span is chosen separately and validated at submit time. Every individually-bookable start is offered. Other listings use their fixed duration.

f
getNextBookableDate

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

f
getTicketFieldsSetting

The merged contact-fields setting for a page's listings: every listing's own setting, folded into one. Takes anything with a listing that names its contact fields, so this module stays free of booking-model imports.

f
groupMemberIds

One group's member listing ids, inactive members included, as a set — the shape the pages filter their loaded listings with.

f
isBookingRangeValid

Whether booking days consecutive days starting on date is valid for a daily listing: every day must be a bookable weekday, fall outside all holidays, and stay within the listing's booking window. Used to enforce the visitor's chosen span on "customisable days" listings at submit time, where the day count isn't known when the date list is rendered.

f
listingDateToCalendarDate

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 listing dates to calendar days.

f
loadListingsAndGroupNames

Every listing and every group name, the two catalogs a page that filters by group reads together.

f
loadSortedListings

Load all listings with holidays and return them sorted. With a filter, only the listings it keeps are returned. Without one, every listing is returned.

f
mergeListingFields

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

f
normalizeDatetime

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
parseIsoDateParam

Parse a user-supplied YYYY-MM-DD value (a ?date= query param): the string when well-formed and a real calendar date, else null.

f
parseListingFields

Parse a comma-separated fields string into individual ContactField names

f
sortListings

Sort listings in unified 3-tier order. Takes anything carrying the values the order is built from, so a narrow picker read sorts the same way a full listing record does.

f
startOfHour

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

f
storedBookingSpan

The stored [date, endDate) booking's start and exclusive end day. The end is one day before the stored exclusive end; with no end stored the span covers only the start day. A stored date the rule refuses stops the request loudly.

f
storedListingFields

The one stored form of a contact-fields setting: the parser's own read of the string, comma-joined back together. Every write to the listings table passes its fields through this. A stored token is then a whole trimmed token, and the badge SQL can compare tokens exactly.

f
widestDatedEntry

The dated entry whose booked range ends last — the stay covering a whole package bundle — or null when every entry is date-less (a standard package). A dated entry with no stored end (a single-day booking, or a legacy row) sorts below any ranged stay. Shared by the collapsed email/SVG displays and the /t package card, so every surface picks the SAME representative stay.

f
withRequiredEmail

Ensure "email" is included in an listing fields setting

Interfaces