Data
WorkingCalendar
The WorkingCalendar class defines working days, shifts, holidays, and start-of-week configuration. It is the central data model used by the Working Calendar Editor and also accepted by the Gantt Chart and Resource Scheduler.
Properties
| workingDays: DayOfWeek[] | Days of the week that are working days. Default: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']. |
| shifts: WorkingShift[] | Working time ranges within each working day. Default: two shifts (8:00–12:00 and 13:00–17:00). |
| nationalHolidays: Date[] | Dates that are non-working regardless of day of week. Default: []. |
| startOfWeek: DayOfWeek | First day of the week for calendar display. Default: 'sunday'. |
import { WorkingCalendar, WorkingShift, TimeOfDay } from '@timelinekit/core';
const cal = new WorkingCalendar();
cal.workingDays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
cal.shifts = [
new WorkingShift(new TimeOfDay(8, 0), new TimeOfDay(12, 0)),
new WorkingShift(new TimeOfDay(13, 0), new TimeOfDay(17, 0)),
];
cal.startOfWeek = 'monday';
cal.nationalHolidays = [
new Date(2026, 0, 1), // New Year
new Date(2026, 11, 25), // Christmas
];
editor.calendar = cal;WorkingShift
A WorkingShift defines a contiguous block of working time within a day.
Properties
| start: TimeOfDay | Start time of the shift. |
| end: TimeOfDay | End time of the shift. |
Methods
| contains(date: Date, excludeStart?: boolean): boolean | Check whether a time falls within this shift. |
| getLengthInMinutes(): number | Duration of this shift in minutes. |
const morning = new WorkingShift(new TimeOfDay(8, 0), new TimeOfDay(12, 0));
console.log(morning.getLengthInMinutes()); // 240TimeOfDay
A simple value type representing a time within a day (hour and minute).
| hour: number | Hour (0–23). |
| minute: number | Minute (0–59). |
import { TimeOfDay } from '@timelinekit/core';
const start = new TimeOfDay(8, 30); // 8:30 AM
const end = new TimeOfDay(17, 0); // 5:00 PMDayOfWeek
A union type representing a day of the week.
type DayOfWeek = 'monday' | 'tuesday' | 'wednesday' | 'thursday'
| 'friday' | 'saturday' | 'sunday';Utility Methods
The WorkingCalendar class provides calculation methods used internally by the Gantt Chart and Resource Scheduler. You can also use them directly in your application logic.
| isWorkingDay(date: Date): boolean | Check whether a date falls on a working day (not a holiday and matching workingDays). |
| getHoursPerDay(): number | Total working hours in a day based on configured shifts. |
| getHoursBetween(time1: Date, time2: Date): number | Calculate working hours between two dates, respecting shifts and non-working days. |
| addHours(date: Date, hours: number): Date | Add working hours to a date, skipping non-working time. Negative values subtract hours. |
| moveToStartShift(date: Date, keepTime?: boolean): Date | Move a date forward to the start of the nearest working shift. |
| moveToEndShift(date: Date, keepTime?: boolean): Date | Move a date backward to the end of the nearest working shift. |
| getEndOfWorkingDay(date: Date): Date | Get the end time of the last shift on a working day. |
| getStartOfWeek(date: Date): Date | Get the start of the week containing the given date, respecting startOfWeek. |
| isEndOfDay(date: Date): boolean | Check whether a time matches the end of the last working shift. |
const cal = new WorkingCalendar();
// Check if a date is a working day
cal.isWorkingDay(new Date(2026, 0, 1)); // false (holiday)
// Calculate working hours between two dates
const hours = cal.getHoursBetween(
new Date(2026, 0, 5, 8, 0),
new Date(2026, 0, 7, 17, 0)
);
// Add 16 working hours (skips non-working time)
const result = cal.addHours(new Date(2026, 0, 5, 8, 0), 16);