businessHours
The hours a place is open: shaded outside in the time grid, and what rules can hold gestures to.
| Type | BusinessHoursInput — boolean | BusinessHoursRule | readonly BusinessHoursRule[] |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/core/src/kernel.ts |
What it does
Section titled “What it does”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.
Example
Section titled “Example”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 });import { Component } from '@angular/core';import type { BusinessHoursInput } from '@dzcalendar/core';import { DZ_CALENDAR } from '@dzcalendar/angular';
@Component({ selector: 'app-agenda', imports: [DZ_CALENDAR], template: `<dz-calendar timeZone="Europe/Paris" [businessHours]="hours" />`,})export class Agenda { // The clinic's hours, kept in Algiers whatever zone the calendar is shown in. readonly hours: BusinessHoursInput = { daysOfWeek: [1, 2, 3, 4, 5], start: '08:00', end: '16:00', timeZone: 'Africa/Algiers' };}import { DzCalendar } from '@dzcalendar/react';
export function Agenda() { return <DzCalendar timeZone="Europe/Paris" businessHours={{ daysOfWeek: [1, 2, 3, 4, 5], start: '08:30', end: '18:00' }} />;}<script setup lang="ts">import { DzCalendar } from '@dzcalendar/vue';</script>
<template> <DzCalendar time-zone="Europe/Paris" :business-hours="{ daysOfWeek: [1, 2, 3, 4, 5], start: '08:30', end: '18:00' }" /></template>In the frameworks it is an input: Angular’s businessHours, React’s businessHours, Vue’s business-hours.
Live demo
Section titled “Live demo”Weekdays open 08:30–12:30 and 14:00–18:00; the rest is shaded.
See also
Section titled “See also”timeZone— the zone rules are read in unless they name theirs.weekends— the days shown.- Drag and drop — gestures held to the hours.