Javascript - Disable dates Calendar

Does anyone know how to add the following two parts to eachtoher? So that I will be able to disable dates based on days and range of dates.

   disabled(date) {
        return [ 0, 6 ].indexOf(date.getDay()) >= 0; 
   },

Adding it to the code below:

disabled: [
  {
    from: new Date().setDate(today.getDate() - xxx),
    to: new Date().setDate(today.getDate() - 49),
  },
  {
    from: today,
    to: new Date().maxDate
  }
],

I am trying so much but with no success. I hope you can help me?

You need to put everyone into single disabled() method and do dates comparison there

1 Like

Thanks for you reaction. I am not sure if I can follow you, can you expand on that? What do you exactly mean with “dates comparison”? I am trying to achieve multiple ways of disabling dates, example:

  1. disable by range of dates
  2. disable by week days

I am understanding that I should put them in one disabled() method. But that is not working really. So how is dates comparing achieving this?

I tried to use “weekendDays: [0, 6]” However this is not working when i am also using “disable:” method.

disabled: [
  {
    from: minDate,
    to: maxDate,
  },
],

Transforms to the following logic:

disabled(date) {
  if (date >= minDate) return true;
  if (date < maxDate) return true;
  return false;
}

hmm ok, so what do I achieve exactly with this? I am confused. So you mean that with this transform now I can add the following line too? If that is what you mean then I understand. Otherwise I am really confused.
return [ 0, 6 ].indexOf(date.getDay()) >= 0;

I have made the following but this is disabling all dates.

disabled(date) {
            if (date >= new Date(2020, 8, 18)) return true;
            if (date < new Date(2020, 8, 20)) return true;
            return [0, 6].indexOf(date.getDay()) >= 0;
        },

If you still have time to reply I would really appreciate it!