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.calendarsdefines the working time of the loaded planProject#analyze:data.calendarsdefines the working time of the analyzed datesschedule:data.calendarsdefines the working time of the plan
Example#
const = ;
Related#
ProjectData- the plan that carriescalendarsSchedulingConfig-calendar_modeanduse_calendarsTaskData- a task'scalendar_id- Working time and calendars - defining calendars and how they combine