[Canonical page](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/calendar-data/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# CalendarData

A named working calendar. Add instances to [`ProjectData.Calendars`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/project-data.md>) and reference them by ID from [`TaskData.CalendarId`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/task-data.md>) and [`ResourceData.CalendarId`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/resource-data.md>). Create one with an object initializer; `Id` is `required`.

## Declaration

```csharp
namespace Plen;

public sealed class CalendarData : IDeepCloneable<CalendarData>
```

## Properties

| Property | Type | Default | Description |
|---|---|---|---|
| `Id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/id.md>) | required | Calendar ID. `"global"` replaces the built-in default calendar. |
| `Worktime` | [`Worktime?`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/worktime.md>) | `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](<https://docs.dhtmlx.com/planning-engine/net/scheduling/working-time-calendars.md>).

## Methods

### DeepClone

```csharp
public CalendarData DeepClone()
```

Returns a copy that shares no [`Worktime`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/worktime.md>), list or dictionary with this one.

### ToString

```csharp
public override string ToString()
```

Returns a readable rendering of `Id` and `Worktime`, for logging.

## Errors

In [`Validation.Strict`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/validation.md>) mode, the call that receives the data throws [`InputException`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/input-exception.md>) with `Kind = `[`InputErrorKind.Validation`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/input-exception.md#inputerrorkind>):

| `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`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/scheduling-config.md>) is `false`. The rules for hours, days and dates are listed on [`Worktime`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/worktime.md>).

## Example

```csharp
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`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/worktime.md>) - the calendar's working time
- [`CalendarMode`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/calendar-mode.md>) - which calendars place the work
- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/project-data.md>) - the snapshot that holds calendars
- [Working time and calendars](<https://docs.dhtmlx.com/planning-engine/net/scheduling/working-time-calendars.md>) - hours, holidays and calendar selection
