Firstly, I have a var that contains a date (just one for the moment):
var disableddates = ["26-05-2018"];
Now I want to check if this date is in a certain date range. The starting date and ending date are coming form a datepicker (with jQuery calendar plugin). These dates are processed like this:
Arrival date:
//Get arrival date from datepicker
function aankomstdatumInput() {
aankomstDatum = document.getElementById("aankomstdatum").value;
document.getElementById("aankomst").innerHTML = aankomstDatum;
var parts = aankomstDatum.split('-');
aankomstDatumDate = new Date(parts[2],parts2[1]-1,parts2[0]);
}
Departure date:
//Get departure date from datepicker
function vertrekdatumInput() {
vertrekDatum = document.getElementById("vertrekdatum").value;
document.getElementById("vertrek").innerHTML = vertrekDatum;
var parts2 = vertrekDatum.split('-');
vertrekDatumDate = new Date(parts2[2],parts2[1]-1,parts2[0]);
}
Now I need a function that checks every date in the disableddates array if it's in the range of aankomstDatumDate and vertrekDatumDate.
Since these two dates are formulated in the following way: Sat May 05 2018 00:00:00 GMT+0200 (Romance Daylight Time), I first have to set the disabled date in the same formulation, so I started the function like this:
function checkDisabledDate{
var parts3 = disableddates.split('-');
disabledDatumDate = new Date(parts3[2],parts3[1]-1,parts3[0]);
}
I think that's a good first step, but then I'm stuck at how I can check if disabledDatumDate is between aankomstDatumDate and vertrekDatumDate and then start and else/if depending if the disabled date is in between the arrival date and departure date or not.