indrimuska / angular-moment-picker

Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
http://indrimuska.github.io/angular-moment-picker/
MIT License
525 stars 226 forks source link

Deactivate two days, and for hours #284

Open cescteruel92 opened 5 years ago

cescteruel92 commented 5 years ago

Hello, is it possible to block the weekend (Saturday and Sunday), with the "selectable" function? Would it be possible to block in number and not in text? (monday = 1, sunday = 7 ...)

Would it also be possible to block hours? for example from 00:00 to 09:00 and from 18:00 to 00:00 (18:00 - 09:00)

Thank you

cescteruel92 commented 5 years ago

To deactivate Saturday and Sunday, and to work in all languages, I have done it in the following way:

ctrl.isSelectable = function (date) {
      return date.format('d') == 1 || date.format('d') == 2 || date.format('d') == 3 || date.format('d') == 4 || date.format('d') == 5;
};

That is to say, I have enabled the days of 1-6 (Monday to Friday)

Now I would disable the hours (from 18:00 to 09:00).

cescteruel92 commented 5 years ago

In the complete script, I found the function of the hours, the only thing I have done is to define the minimum time (default 0, with the maximum time 23)

// Day View hoursFormat: 'HH:[00]', hoursStart: 9, hoursEnd: 18,

Now I just need, disable the 14 that is the lunch break.