bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

Use dateValidator for two purposes #166

Open robfaas opened 8 years ago

robfaas commented 8 years ago

Is it possible to make some specific dates invalid AND certain weekdays? The script below is not working. Any suggestions?

dateValidator: rome.val.except(['2016-05-06', '2016-05-13']), dateValidator: function (d) { return (moment(d).day() !== 3); },

qmarcos commented 5 years ago

Hi robfaas,

Probably at this time your doubt is solved... or not used today, but if someone else is looking for something similar to your original needs (that are exactly the same than mine), you can achieve the same results this way:

dateValidator: function (d) {
    var HOLIDAY_LIST = ['25/12/2018', '01/01/2019'];
    var isHoliday = HOLIDAY_LIST.indexOf(moment(d).format('DD/MM/YYYY'))>=0;

    return (!isHoliday && moment(d).day() !== 0);
}

Where the isHoliday flag has the same effect than the except function provided internally, and we format the d parameter to match the holidays strings format.

Hope it helps!

robfaas commented 5 years ago

Hi qmarcos,

Thanks, it is indeed solved now. By using another script :) I'm using https://github.com/flatpickr/flatpickr now.