Skip to content

businessHours

The hours a place is open: shaded outside in the time grid, and what rules can hold gestures to.

TypeBusinessHoursInput — boolean | BusinessHoursRule | readonly BusinessHoursRule[]
Defaultnot set
Live update (update())Yes
Declared inpackages/core/src/kernel.ts

Three shapes:

  • true: Monday to Friday, 09:00 to 17:00; false: none.
  • One rule: { daysOfWeek: [1, 2, 3, 4, 5], start: '08:30', end: '18:00' }.
  • Several rules, for a lunch break or a different Saturday: [{ daysOfWeek: [1, 2, 3, 4, 5], start: '08:30', end: '12:30' }, { daysOfWeek: [1, 2, 3, 4, 5], start: '14:00', end: '18:00' }].

daysOfWeek are ISO weekdays (1 Monday … 7 Sunday). start and end are wall times; '24:00' is the next midnight, and an end at or before the start crosses midnight (22:00–06:00, a night shift). A rule is read in the calendar’s zone, or in its own timeZone: a clinic in Algiers keeps its hours on a calendar shown in Paris. On the day the clocks change, a shift has its true length.

Outside these hours the time grid is shaded, and a day grid marks the days with none. With rules: { constraint: 'businessHours' }, a drag or a resize outside them is refused.

import { createCalendar } from '@dzcalendar/dom';
const calendar = createCalendar(element, {
timeZone: 'Europe/Paris',
businessHours: [
{ daysOfWeek: [1, 2, 3, 4, 5], start: '08:30', end: '12:30' },
{ daysOfWeek: [1, 2, 3, 4, 5], start: '14:00', end: '18:00' },
],
editable: true,
// A drag or a resize outside the hours is refused.
rules: { constraint: 'businessHours' },
});
// Later: the default hours (Monday to Friday, 9:00–17:00).
calendar.update({ businessHours: true });

In the frameworks it is an input: Angular’s businessHours, React’s businessHours, Vue’s business-hours.

Weekdays open 08:30–12:30 and 14:00–18:00; the rest is shaded.