CalendarMode#

Selects which calendars place a task's work. Set it as SchedulingConfig.calendarMode. The default is RESOURCE.

Declaration#

package org.dhtmlx.plen;

public enum CalendarMode {
  RESOURCE,
  TASK,
  TASK_INHERITED
}

Variants#

Variant Description
RESOURCE Default. Each assignment works on its resource's calendar, intersected with the task's calendar when both have one. A resource's calendarId must name a calendar in ProjectData.calendars.
TASK Each task works on its own calendar only: TaskData.calendarId, else the global calendar. Resource calendars are ignored, and a resource's calendarId isn't resolved.
TASK_INHERITED Same as TASK, except that a task without a calendarId uses the calendar of its nearest ancestor that has one.

Only TASK_INHERITED inherits calendars from summary tasks. With SchedulingConfig.useCalendars set to false, every calendar is flat 24/7 time, so the mode has no effect on dates.

Working-time calendars covers how each mode combines calendars and places work.

Example#

import org.dhtmlx.plen.*;
import java.util.List;

public class InheritedCalendar {
    public static void main(String[] args) throws Exception {
        Moment start = Moment.fromYmdHm(2026, 8, 14, 8, 0);

        CalendarData sixDay = new CalendarData()
            .withId(Id.str("six-day"))
            .withWorktime(new Worktime()
                .withDays(new boolean[] {false, true, true, true, true, true, true})); // Sun..Sat

        ProjectData data = new ProjectData()
            .withConfig(new SchedulingConfig().withCalendarMode(CalendarMode.TASK_INHERITED))
            .withCalendars(List.of(sixDay))
            .withTasks(List.of(
                new TaskData(Id.str("phase"))
                    .withTaskType(TaskType.SUMMARY)
                    .withCalendarId(Id.str("six-day")),
                // No calendarId: works on "six-day", taken from "phase".
                new TaskData(Id.str("pour"))
                    .withParent(Id.str("phase"))
                    .withStartDate(start)
                    .withDuration(2.0)));

        ScheduleResult result = Engine.schedule(data, new SolveOptions().withIncludeUnchanged(true));
        for (Mutation update : result.updates) {
            System.out.println(update.id + ": " + update.startDate + " -> " + update.endDate);
        }
    }
}