Skip to content

formats

How each place of the calendar writes its dates and times — the platform’s options, or a function.

TypeFormats
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/calendar.ts

One entry per place: title (the header’s, see titleFormat), dayHeader, dayCell, slotLabel (the hours’ labels), eventTime, eventTimeRange, listDay, listDaySide, monthHeader, morePopover, and weekNumber. Each takes Intl.DateTimeFormat options ({ hour: 'numeric' }) or a function of its context ({ date | time | start, end, locale, … }) returning the text — weekNumber a function only. A place not given is written as by default, in locale (and displayCalendar).

update({ formats }) replaces the formats given before.

import { createCalendar } from '@dzcalendar/dom';
createCalendar(element, {
timeZone: 'Europe/Paris',
weekNumbers: true,
formats: {
slotLabel: { hour: 'numeric' },
dayHeader: { weekday: 'short', day: 'numeric' },
// A function: the week's number with a prefix of the clinic's.
weekNumber: ({ week }) => `Wk ${week}`,
},
});

In Angular and Vue it goes in options; in React it is a prop.

The gutter labelled by the hour alone (09, 10…), the days by their short weekday and number (Mon 19).