scheduler.date.add_day not getting called?

I’m working on a scheduler which skips weekends in “day” and “timeline” view.
I have the following code for my scheduler:

//why this is not working
scheduler.date.add_day = function(date, inc) {
if ((date.getDay() == 5 && inc > 0) || (date.getDay() == 1 && inc < 0)) { //friday / monday
return scheduler.date.add(date, inc * 3, “day”);
} else {
return scheduler.date.add(date, inc * 1, “day”);
}
}

        scheduler.ignore_day = function(date) {
            if (date.getDay() == 6 || date.getDay() == 0) //hides Saturdays and Sundays
                return true;
        };

        scheduler.date.add_timeline = function(date, inc) {
            if ((date.getDay() == 5 && inc > 0) || (date.getDay() == 1 && inc < 0)) { //friday / monday
                return scheduler.date.add(date, inc * 3, "day");
            } else {
                return scheduler.date.add(date, inc * 1, "day");
            }

        }

While my scheduler.date.add_timeline got called when I navigate, scheduler.date.add_day did not get called at all. And scheduler.ignore_day works well. This makes me so confused. Is this intended or something wrong with my code?

for scheduler.date.add_{view name} see:
docs.dhtmlx.com/scheduler/custom_views.html - 5

Hello,
adding days is one of the basic operations of a scheduler, so there is has no public method to override.
If you want to skip weekends when you scroll day view forward and backward, you could use onBeforeViewChanged event

Here is a demo:
docs.dhtmlx.com/scheduler/snippet/7d420140

Docs:
docs.dhtmlx.com/scheduler/api__s … event.html

I am skipping the weekends in the day view like this:

scheduler.attachEvent("onBeforeViewChange", function(old_mode, old_date, mode, date){
    // see https://docs.dhtmlx.com/scheduler/api__scheduler_onbeforeviewchange_event.html
    // see https://forum.dhtmlx.com/t/scheduler-date-add-day-not-getting-called/35633
    if (mode == "day") {
      if (date.getDay() == 6) {
        // Saturday, we come from Friday and go to Monday
        scheduler.setCurrentView(scheduler.date.add(date, 2, "day"));
        return false;
      } else if (date.getDay() == 0) {
        // Sunday, we come from Monday and go to Friday
        scheduler.setCurrentView(scheduler.date.add(date, -2, "day"));
        return false;
      }
    }
    return true;
});

I think, this can be used to skip specific dates as well.

See also: