CalendarData#
A named working calendar. Add instances to ProjectData.Calendars and reference them by ID from TaskData.CalendarId and ResourceData.CalendarId. Create one with an object initializer; Id is required.
Declaration#
namespace Plen;
public sealed class CalendarData : IDeepCloneable<CalendarData>
Properties#
| Property | Type | Default | Description |
|---|---|---|---|
Id |
Id |
required | Calendar ID. "global" replaces the built-in default calendar. |
Worktime |
Worktime? |
null |
Working hours, weekdays and date exceptions. null gives the built-in working time: Monday to Friday, 08:00-12:00 and 13:00-17:00. |
The "global" calendar#
Every project has a calendar with the ID "global". Without a CalendarData of that ID, it's Monday to Friday, 08:00-12:00 and 13:00-17:00. A CalendarData with Id = "global" replaces it. Which tasks and assignments fall back to "global" is covered in Working time and calendars.
Methods#
DeepClone#
public CalendarData DeepClone()
Returns a copy that shares no Worktime, list or dictionary with this one.
ToString#
public override string ToString()
Returns a readable rendering of Id and Worktime, for logging.
Errors#
In Validation.Strict mode, the call that receives the data throws InputException with Kind = InputErrorKind.Validation:
Path |
When |
|---|---|
calendars[i] |
Two calendars share an ID ("duplicate calendar id"). IDs compare by their text form, so 1 and "1" collide. In Validation.Repair mode the last one wins instead. |
calendars[i] |
The calendar has no working time at all: no working hours on any weekday and no date exception with hours ("calendar has no working time"). |
These checks also run when UseCalendars in SchedulingConfig is false. The rules for hours, days and dates are listed on Worktime.
Example#
using Plen;
var partTime = new CalendarData
{
Id = "part-time",
Worktime = new Worktime
{
// Monday, Wednesday and Friday; index 0 is Sunday.
Days = [false, true, false, true, false, true, false],
Hours = [new TimeRange(9 * 60, 13 * 60)],
},
};
var data = new ProjectData
{
Calendars = [partTime],
Tasks =
[
new TaskData("1")
{
StartDate = Moment.FromYmdHm(2026, 3, 2, 9, 0),
Duration = 3,
CalendarId = "part-time",
},
],
};
Related#
Worktime- the calendar's working timeCalendarMode- which calendars place the workProjectData- the snapshot that holds calendars- Working time and calendars - hours, holidays and calendar selection