I have this code through which I show a future working day, thus excluding weekends. I would also like to exclude personalized holiday dates, in which case the same thing happens (count ++, I guess).
For example, I would like to exclude these dates: ["2019-11-6", "2019-11-13"]
How can I integrate this into the code?
I need this to show a future delivery date on a business day, excluding weekends and some custom dates.
I've read and tested countless similar questions here on StackOverflow, but I haven't found anything that works.
jQuery(function($) {
var monthNames = ["gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"];
var dayNames = ["domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"]
var endDate = "",
noOfDaysToAdd = 1,
count = 0;
var someDate = new Date();
var numberOfDaysToAdd = noOfDaysToAdd;
someDate.setDate(someDate.getDate());
while (count < noOfDaysToAdd) {
endDate = new Date(someDate.setDate(someDate.getDate() + 1));
if (endDate.getDay() != 0 && endDate.getDay() != 6) {
count++;
}
}
$('#Date').html(dayNames[endDate.getDay()] + ' ' + endDate.getDate() + ' ' + monthNames[endDate.getMonth()] + ' ' + endDate.getFullYear());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Date"></div>
The code works well for the exclusion of weekends, but I would like help to add customized holiday dates as well.