You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// adding a calendar with a new config (the "days" property is set as array)
20
+
const calendarId = gantt.addCalendar({
21
+
id:"custom", // optional
22
+
worktime: {
23
+
hours: ["8:00-17:00"],
24
+
days: [1, 1, 1, 1, 1, 1, 1]
25
+
}
26
26
});
27
27
28
-
var calendar = gantt.getCalendar(calendarId);
28
+
// adding a calendar with a new config (the "days" property is set as object)
29
+
const calendarId = gantt.addCalendar({
30
+
id: "global", // the calendar id is optional
31
+
worktime: {
32
+
hours: ["8:00-12:00", "13:00-17:00"], // global work hours for weekdays
33
+
days: {
34
+
weekdays: [0, 1, 1, 1, 1, 1, 0],
35
+
dates: {
36
+
"2025-04-06": true, // override work hours for a specific date
37
+
"2025-04-08": false,
38
+
"2025-04-09": ["9:00-15:00"]
39
+
}
40
+
},
41
+
customWeeks: {
42
+
lastMonthOfTheYear: {
43
+
from: new Date(2025, 11, 1),
44
+
to: new Date(2026, 0, 1),
45
+
hours: ["9:00-13:00"],
46
+
days: {
47
+
weekdays: [0, 1, 1, 1, 1, 0, 0],
48
+
dates: {
49
+
"2025-12-08": true,
50
+
"2025-12-09": false,
51
+
"2025-12-10": ["9:00-15:00"]
52
+
}
53
+
}
54
+
}
55
+
}
56
+
}
57
+
});
58
+
59
+
const calendar = gantt.getCalendar(calendarId);
29
60
30
61
@template: api_method
31
62
@descr:
@@ -34,59 +65,96 @@ The calendar configuration object can contain the following attributes:
34
65
- <spanclass=subproperty>**id?**</span> - (*string | number*) - optional, the calendar id
35
66
- <spanclass=subproperty>**worktime?**</span> - (*object*) - an object that sets the worktime in days and hours. It can include:
36
67
-**_hours?_** - (*string[] | number[] | boolean*) - optional, an array with global working hours, sets the start and end hours of the task
37
-
-**_days?_** - (*WorkDaysTuple*) - optional, an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day
68
+
-**_days?_** - (*WorkDaysTuple* | *object*) - optional, it can be:
69
+
- either an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day
70
+
- or an object that contains weekdays and dates. It can include:
71
+
- **_weekdays?_** - (*WorkDaysTuple*) optional, an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day
72
+
- **_dates?_** - (*object*) optional, an object with working time settings for specified dates. The object can contain a number of key: value pairs where:
73
+
- key is a date set as a string
74
+
- value is either an array of working hours as 'from'-'to' pairs or a boolean ('false' value sets a day-off, 'true' applies the default hours (["8:00-17:00"]))
38
75
-**_customWeeks?_** - (*object*) - optional, an object with different working-time rules for different periods of time. The object can contain a set of key:value pairs where key is the name of a time span and value is an object with a list of attributes.
39
76
-**_[timespan: string]_** - (*object*) - the time span with the working time settings. The name of that object is used as the name of the time span
40
77
- **_from_** - (*Date*) - the date when the time span is scheduled to begin
41
78
- **_to_** - (*Date*) - the date when the time span is scheduled to be completed
42
79
- **_hours?_** - (*Array<string | number>*) - optional, an array of working hours as 'from'-'to' pairs.'false' value sets a day-off, 'true' (default value) applies the default hours (["8:00-17:00"])
43
-
- **_days?_** - (*WorkDaysTuple | boolean*) - optional, an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day.
44
-
80
+
- **_days?_** - (*WorkDaysTuple* | *object*) - optional, it can be:
81
+
- either an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day
82
+
- or an object that contains weekdays and dates. It can include:
83
+
- **_weekdays?_** - (*WorkDaysTuple*) optional, an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day
84
+
- **_dates?_** - (*object*) optional, an object with working time settings for specified dates. The object can contain a number of key: value pairs where:
85
+
- key is a date set as a string
86
+
- value is either an array of working hours as 'from'-'to' pairs or a boolean ('false' value sets a day-off, 'true' applies the default hours (["8:00-17:00"]))
45
87
46
88
47
-
###Setting individual working hours for a day
89
+
###Setting individual working hours for a day
48
90
49
-
Instead of the number of a week day, you can also set custom working hours for this day.<br>
50
-
For example:
91
+
Instead of the number of a week day, you can also set custom working hours for this day.
92
+
For example:
51
93
52
94
~~~js
53
-
var calendar = {
54
-
id:"calendar1", // optional
95
+
constcalendar= {
96
+
id:"calendar1", // optional
55
97
worktime: {
56
98
hours: ["8:00-17:00"],
57
-
days: [0, 1, 1, 1, ["12:00-17:00"], 1, 0]
99
+
days: [0, 1, 1, 1, ["12:00-17:00"], 1, 0]/*!*/
58
100
}
59
101
}
60
102
~~~
61
103
62
104
where ["12:00-17:00"] are working hours from 12 pm to 17 pm for Thursday.
63
105
64
-
65
106
### Setting worktime for different time intervals
66
107
67
-
There is the ability to configure different working time rules for different periods of time by using the **customWeeks** attribute:
108
+
There is a possibility to configure different working time rules for different periods of time by using the **customWeeks** attribute:
68
109
69
110
~~~js
70
-
// adding a calendar with a new config
71
111
gantt.addCalendar({
72
-
id:"default", // optional
73
-
worktime: {
74
-
hours: ["8:00-17:00"],
75
-
days: [1, 1, 1, 1, 1, 1 ,1],
76
-
customWeeks: {
77
-
winter: {
78
-
from:newDate(2020, 11, 1),// December 1st, 2020
79
-
to:newDate(2021, 2, 1),// March 1st 00:00, 2021
80
-
hours: ["9:00-13:00", "14:00-16:00"],
81
-
days: [1, 1, 1, 1, 0, 0, 0]
82
-
}
83
-
}
84
-
}
112
+
id:"global", // optional
113
+
worktime: {
114
+
hours: ["8:00-17:00"],
115
+
days: [1, 1, 1, 1, 1, 1, 1],
116
+
customWeeks: {
117
+
winter: {
118
+
from:newDate(2025, 11, 1),// December 1st, 2025
119
+
to:newDate(2026, 2, 1),// March 1st, 00:00, 2026
120
+
hours: ["9:00-13:00", "14:00-16:00"],
121
+
days: [1, 1, 1, 1, 0, 0, 0]
122
+
}
123
+
}
124
+
}
85
125
});
126
+
~~~
127
+
### Setting worktime for certain dates
86
128
129
+
You can also specify working hours for certain dates by setting them in the **_dates_** property of the **_days_** object (both for the **worktime** attribute and the **customWeeks** property). For example:
87
130
131
+
~~~js
132
+
constcalendar= {
133
+
id:"calendar1", // optional
134
+
worktime: {
135
+
hours: ["8:00-17:00"],
136
+
days: {
137
+
dates: {
138
+
"2025-04-09": ["9:00-15:00"]
139
+
}
140
+
},
141
+
customWeeks: {
142
+
winter: {
143
+
from:newDate(2025, 11, 1), // December 1st, 2025
144
+
to:newDate(2026, 2, 1), // March 1st, 00:00, 2026
145
+
hours: ["9:00-13:00", "14:00-16:00"],
146
+
days: {
147
+
dates: {
148
+
"2026-01-02": ["9:00-15:00"]
149
+
}
150
+
}
151
+
}
152
+
}
153
+
}
154
+
}
88
155
~~~
89
-
156
+
157
+
90
158
@relatedsample:
91
159
92
160
09_worktime/06_task_calendars.html
@@ -103,5 +171,6 @@ api/gantt_calendar_other.md
103
171
desktop/working_time.md#multipleworktimecalendars
104
172
105
173
@changelog:
106
-
- the **customWeeks** property is added in v7.1;
174
+
- the possibility to specify the **_days_** property as *object* with weekdays and dates is added in v9.1
0 commit comments