formats
How each place of the calendar writes its dates and times — the platform’s options, or a function.
| Type | Formats |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/calendar.ts |
What it does
Section titled “What it does”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.
Example
Section titled “Example”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}`, },});import { Component } from '@angular/core';import { DZ_CALENDAR } from '@dzcalendar/angular';
@Component({ selector: 'app-agenda', imports: [DZ_CALENDAR], template: `<dz-calendar timeZone="Europe/Paris" [options]="{ formats: { slotLabel: { hour: 'numeric' } } }" />`,})export class Agenda {}import { DzCalendar } from '@dzcalendar/react';
export function Agenda() { return <DzCalendar timeZone="Europe/Paris" formats={{ slotLabel: { hour: 'numeric' } }} />;}<script setup lang="ts">import { DzCalendar } from '@dzcalendar/vue';</script>
<template> <DzCalendar time-zone="Europe/Paris" :options="{ formats: { slotLabel: { hour: 'numeric' } } }" /></template>In Angular and Vue it goes in options; in React it is a prop.
Live demo
Section titled “Live demo”The gutter labelled by the hour alone (09, 10…), the days by their short weekday and number (Mon 19).
See also
Section titled “See also”titleFormat— the title, at creation.locale— the language.displayEventTime— an event’s time shown or not.