React checkout
Hours and duration
We compute length from the start and end you already set.
Do not add a Duration field. Do not store hours in the database. Catalog
GET /v1/events/{eventId} still returns starts_at, ends_at, and
timezone as ISO timestamps. When doors exist, the same payload includes
doors_open. Series date rows on GET /v1/productions/{productionId}/events
include those clocks per show.
Helper
@axyn/web-sdk exports formatEventHoursParts and
formatSeriesHoursOverview. Hosted AXYN uses the same functions.
import {
formatEventHoursParts,
formatSeriesHoursOverview,
} from '@axyn/web-sdk';
const independent = formatEventHoursParts({
startsAt: event.starts_at,
endsAt: event.ends_at,
timezone: event.timezone,
doorsOpen: event.doors_open,
});
// independent.duration is "2 hours" when both clocks exist, or null.
const series = formatSeriesHoursOverview({
shows: productionEvents.map((show) => ({
startsAt: show.starts_at,
endsAt: show.ends_at,
timezone: show.timezone,
doorsOpen: show.doors_open,
})),
});
Rules
- Missing
ends_atomits duration. Never guess. Never show 0 hours. - Overnight end is real elapsed time (9pm to 2am is 5 hours). The date line names both calendar days.
- Doors print only when
doors_openis a different clock from start. - Series overview is first show start through last show end (calendar days). Each included show has its own start, end, and duration.
- Keep showing the clocks. Hours are extra, not a replacement.