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


# CalendarMode

Selects which calendars place a task's work: the calendars of the assigned resources, or task calendars only. It's the type of [`SchedulingConfig::calendar_mode`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/scheduling-config.md#calendar_mode>). The default is `CalendarMode::Resource`.

With the `serde` feature, `CalendarMode` implements `Serialize` and `Deserialize`. Variants serialize in kebab-case: `"resource"`, `"task"`, `"task-inherited"`.

## Declaration

```rust
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum CalendarMode {
    #[default]
    Resource,
    Task,
    TaskInherited,
}
```

## Variants

| Variant | Description |
|---|---|
| `Resource` | Default. Each assignment works on its resource's calendar intersected with the task's calendar. A task with several assignment calendars spans all of its assignments. |
| `Task` | Task calendars only. Resource calendars are ignored. This is the dhtmlxGantt model. |
| `TaskInherited` | Task calendars only, as in `Task`. A task without its own calendar uses the calendar of the nearest ancestor that has one. |

Only `TaskInherited` inherits calendars from parent tasks. For how the calendars combine, see [Working-time calendars](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/working-time-calendars.md>).

## Methods

### task_only

```rust
pub fn task_only(self) -> bool
```

Returns `true` when resource calendars aren't used: `Task` and `TaskInherited`.

### inherits

```rust
pub fn inherits(self) -> bool
```

Returns `true` when tasks inherit their parent's calendar: `TaskInherited` only.

## Example

```rust
use plen_core::{CalendarMode, ProjectData, SchedulingConfig};

fn main() {
    let data = ProjectData {
        config: SchedulingConfig {
            calendar_mode: CalendarMode::TaskInherited,
            ..Default::default()
        },
        ..Default::default()
    };

    assert!(data.config.calendar_mode.task_only());
    assert!(data.config.calendar_mode.inherits());
    assert_eq!(CalendarMode::default(), CalendarMode::Resource);
}
```

## Related

- [`CalendarData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/calendar-data.md>) - the calendars this mode chooses between
- [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/resource-data.md#calendar_id>) - its `calendar_id` is read only in `Resource` mode
- [`TaskData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/task-data.md>) - its `calendar_id` is the task calendar in every mode
- [Working time and calendars](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/working-time-calendars.md>) - how task and resource calendars combine in each mode
- [Import from dhtmlxGantt](<https://docs.dhtmlx.com/planning-engine/rust/how-to/import-from-dhtmlxgantt.md>) - picks the mode that matches gantt's calendar model
