CalendarData#

A working-time calendar: which hours of which days count as working time. Pass calendars in ProjectData.calendars. Tasks and resources pick one through their calendar_id. Input only: no call returns it.

Fields#

Field Type Default Description
id Id required Calendar id, unique among the calendars. The id "global" replaces the default calendar.
worktime object Mon-Fri, 8:00-12:00 and 13:00-17:00 Working-time rules. null reads as omitted.
worktime.hours string[] ["8:00-12:00", "13:00-17:00"] Working hours of a working day, as "H:MM-H:MM" ranges. 24:00 is a valid end. An end at or before the start runs past midnight.
worktime.days (boolean | number)[] [false, true, true, true, true, true, false] Exactly 7 entries, Sunday first. true or a non-zero number is a working day with hours; false or 0 is a day off.
worktime.dates Record<string, boolean | number | string[]> {} Exceptions per date, keyed "YYYY-MM-DD". true or a non-zero number is a working day with hours, false or 0 is a day off, and an array of ranges gives that day its own hours. An exception overrides days.

A field left out of worktime keeps its default, so { hours: ["9:00-18:00"] } is a Monday-to-Friday calendar with those hours.

Without a calendar named "global", the default calendar is Monday to Friday, 8:00-12:00 and 13:00-17:00. How tasks and resources combine their calendars is set by SchedulingConfig.calendar_mode. With use_calendars: false, every calendar is ignored and time is flat 24/7. See Working-time calendars.

Validation#

Each failure throws an InputError whose path points into calendars:

path When
calendars[i] Two calendars share an id
calendars[i] The calendar has no working time at all
calendars[i].worktime.hours A range lies outside 00:00..24:00
calendars[i].worktime.dates[YYYY-MM-DD] A date's range lies outside 00:00..24:00
under calendars[i].worktime A range isn't "H:MM-H:MM", days doesn't have 7 entries, a dates key isn't a date, or an entry of days is an array
under calendars[i].worktime customWeeks (or custom_weeks) is present; it isn't supported

A calendar_id that names no calendar is reported on the task or resource that holds it.

Used by#

  • Project#solve: data.calendars defines the working time of the loaded plan
  • Project#analyze: data.calendars defines the working time of the analyzed dates
  • schedule: data.calendars defines the working time of the plan

Example#

const calendars = [
  // Replace the default calendar: 9 to 18 with a lunch break, Monday to Friday.
  { id: "global", worktime: { hours: ["9:00-13:00", "14:00-18:00"] } },
  // A night shift, Monday to Saturday, with a holiday and a short day.
  {
    id: "night",
    worktime: {
      hours: ["22:00-6:00"],
      days: [false, true, true, true, true, true, true],
      dates: {
        "2026-12-25": false,
        "2026-12-31": ["22:00-2:00"],
      },
    },
  },
];