setWorkTime will not unset a Sat or Sun as a working day

tried but found, while use a setWorkTime, it will set a working day to a non-working day, but cannot set a non-working day to a working day, like in China, it was a shift working day on 2/20 because of Chinese New Year Holidays. but I cannot set this day as a working day.

is this designed that Sat and Sun will not be set to a non-working day while using [date] option?

1 Like

Hello @Kevin_Tian ,

You should be able to make all Saturdays/Sundays or the specific weekend as working:

This fragment will make all Saturdays as working days:

gantt.setWorkTime({day : 6});

Demo all working Saturdays:
http://snippet.dhtmlx.com/5/97e931e41

And this one should make the specific weekend a working day(Sunday 08):

gantt.setWorkTime({date : new Date(2018, 3, 08)});

Demo:
http://snippet.dhtmlx.com/5/7670229de

It may not work in your case if you are using not a global worktime calendar, but task/resource level calendars:
https://docs.dhtmlx.com/gantt/desktop__working_time.html#assigningcalendartotask

In this case, you should change work time for these calendars, instead of changing global settings:

Example with task level calendar:

gantt.addCalendar({
    id:"custom", // optional
    worktime: {
        hours: ["8:00-17:00"],
        days: [ 0, 0, 1, 1, 1, 1 ,0]
    }
});
var calendar = gantt.getCalendar("custom");
calendar.setWorkTime({date : new Date(2018, 3, 08)});

Demo:
http://snippet.dhtmlx.com/5/911408952

If it’s not your case, could you please provide more details on how to reproduce your issue, or reproduce it in our snippet tool(open the demo above => reproduce the issue on “HTML/CODE/DATA” tabs => click the “Share” button) and post here the new link?

1 Like