About customWeeks.Can't you set additional dates after setting customWeeks?

Hello,
I want to set Monday in time period A as a holiday and Tuesday in time period B as a holiday.
Then one of those days is a holiday

I found that after using customWeeks, setting a day within a separate time period as a holiday does not take effect. Why?

Specific steps are as follows

When I set the following code:

var calendarId = gantt.addCalendar({
id:“global”, // optional
worktime: {
hours: [“8:00-17:00”],
days: [ 1, 1, 1, 1, 1, 1 ,1],
customWeeks: {
winter: {
from: new Date(2018, 11, 1),// December 1st, 2018
to: new Date(2019, 2, 1),// March 1st 00:00, 2019,
hours: [“9:00-18:00”],
days: [ 1, 1, 1, 1, 0, 0, 0]
},
winter2: {
from: new Date(2018, 11, 10),// December 1st, 2018
to: new Date(2019, 2, 1),// March 1st 00:00, 2019,
hours: [“9:00-18:00”],
days: [ 0, 0, 0, 0, 1, 1, 1]
}
}
},

});

Then I set up the code and it doesn’t work.
Why?
Can’t you set additional dates after setting customWeeks?

@ramil

8j4qqq9j

let calendar = gantt.getCalendar(calendarId);
calendar.setWorkTime({
date: new Date(2018, 11, 10),
hours: false,
});

Hello, @ramil
Can’t I set exception holidays after I set custom?

Hello,
If you check the calendar settings, you can see that the working time settings for the date are there:


If you have a customWeeks period, it has a higher priority for that date. So, the settings you added are ignored.

If you want to modify the customWeeks settings, you need to use the customWeeks object in the setWorkTime method:
https://docs.dhtmlx.com/gantt/whatsnew.html#x6629x80x6630x:~:text=setWorkTime%20method%20now%20supports%20setting%20rules%20for%20dates%20inside%20customWeeks

setWorkTime Gantt Docs)%3B-,customWeeks,-an%20object%20with

It doesn’t work the same way as an exception date, you can only modify the existing periods. This means, you need to create several periods. And it is better for the periods to not overlap or one period will have a higher priority over the others.

Here is the updated snippet:
https://snippet.dhtmlx.com/34n5u9v5

Hi, If these two times overlap, will the upper one take effect and the lower one not? Or not necessarily?

Set it like this:

customWeeks: {
winter: {
from: new Date(2018, 11, 12),// December 1st, 2018
to: new Date(2018, 11, 13),// March 1st 00:00, 2019,
hours: [“9:00-18:00”],
days: [ 1, 1, 1, 1, 1, 1, 1]
},
winter2: {
from: new Date(2018, 11, 10),// December 1st, 2018
to: new Date(2018, 1, 15),// March 1st 00:00, 2019,
hours: [“9:00-18:00”],
days: [ 0, 0, 0, 0, 0, 0, 0]
}
}

Just like above,winter belongs to winter2.
winter Is it definitely going to take effect?
Or two objects winter and winter2 must not overlap, otherwise there will be unpredictable errors?

@ramil
Hello,take a look at the reply above.

Hello,
If the intervals overlap, the first declared interval has a higher priority.
The following screenshots demonstrate that:


The last configuration you shared is not valid for winter2 as the interval ends before it starts.
If you mean the 2019 year, the winter interval will work as it is declared first:
https://snippet.dhtmlx.com/yxbzybmb

If it is declared second, it won’t work:
https://snippet.dhtmlx.com/vuvtavel