$(departure_date).datepicker("show");
});
- var extraDay, end, arrival, currentDate, currentDate2,
- requiredDate, requiredDate1, minDays, departure,
- stay, d, dd, m, y;
+ var extraDay, end, arrival, currentDate, currentDate2, currentDatePlusOne, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m,mm, y;
+
$(document).on('change', '#arriveOff', function () {
currentDate = $("#arriveOff").val();
+ currentDate = currentDate.replace(/-/g, "/");
+
currentDate = new Date(currentDate);
+ currentDatePlusOne = new Date(currentDate);
- // this section is used to circumvent issues with selecting the last day of the month without a proper rollover to the following month.
- currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
- currentDate.setDate(currentDate.getDate());
+ currentDatePlusOne.setDate(currentDate.getDate() + 1);
- dd = currentDate.getDate() + 1;
+ dd = currentDatePlusOne.getDate();
if (dd <= 9) {
dd = '0' + dd;
}
- d = currentDate.getDate();
+
+ console.debug(dd);
+ d = currentDate.getUTCDate();
if (d <= 9) {
d = '0' + d;
}
- m = currentDate.getMonth() + 1;
+ m = currentDate.getUTCMonth() + 1;
if (m <= 9) {
m = '0' + m;
}
+ mm = currentDatePlusOne.getUTCMonth() + 1;
+ if (mm <= 9) {
+ mm = '0' + mm;
+ }
y = currentDate.getFullYear();
// this variable is for passing to booking site
requiredDate = y + '-' + m + '-' + d;
- minDays = y + '-' + m + '-' + dd;
+ minDays = y + '-' + mm + '-' + dd;
$("#departOff").attr("min", minDays);
- if (requiredDate <= $("#arriveOff").attr("min")) {
- minDays = $("#arriveOff").attr("min");
- $("#arriveOff").val(minDays);
- }
+ $("#departOff").val("");
+
});
// restrict departure date ///////////////////////////////
$(document).on('change', '#departOff', function () {
currentDate2 = $("#departOff").val();
+ currentDate2 = currentDate2.replace(/-/g, "/");
currentDate2 = new Date(currentDate2);
- currentDate2 = new Date(currentDate2.getUTCFullYear(), currentDate2.getUTCMonth(),currentDate2.getUTCDate());
- currentDate2.setDate(currentDate2.getDate());
+
if($("#departOff").val() <= requiredDate){
$("#departOff").val(minDays);
}
$(departure_date).datepicker("show");
});
- var extraDay, end, arrival, currentDate, currentDate2,
- requiredDate, requiredDate1, minDays, departure,
- stay, d, dd, m, y;
+ var extraDay, end, arrival, currentDate, currentDate2, currentDatePlusOne, requiredDate, requiredDate1, minDays, departure, stay, d, dd, m,mm, y;
+
$(document).on('change', '#arriveOff', function () {
currentDate = $("#arriveOff").val();
+ currentDate = currentDate.replace(/-/g, "/");
+
currentDate = new Date(currentDate);
+ currentDatePlusOne = new Date(currentDate);
- // this section is used to circumvent issues with selecting the last day of the month without a proper rollover to the following month.
- currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate());
- currentDate.setDate(currentDate.getDate());
+ currentDatePlusOne.setDate(currentDate.getDate() + 1);
- dd = currentDate.getDate() + 1;
+ dd = currentDatePlusOne.getDate();
if (dd <= 9) {
dd = '0' + dd;
}
- d = currentDate.getDate();
+
+ console.debug(dd);
+ d = currentDate.getUTCDate();
if (d <= 9) {
d = '0' + d;
}
- m = currentDate.getMonth() + 1;
+ m = currentDate.getUTCMonth() + 1;
if (m <= 9) {
m = '0' + m;
}
+ mm = currentDatePlusOne.getUTCMonth() + 1;
+ if (mm <= 9) {
+ mm = '0' + mm;
+ }
y = currentDate.getFullYear();
// this variable is for passing to booking site
requiredDate = y + '-' + m + '-' + d;
- minDays = y + '-' + m + '-' + dd;
+ minDays = y + '-' + mm + '-' + dd;
$("#departOff").attr("min", minDays);
- if (requiredDate <= $("#arriveOff").attr("min")) {
- minDays = $("#arriveOff").attr("min");
- $("#arriveOff").val(minDays);
- }
+ $("#departOff").val("");
+
});
// restrict departure date ///////////////////////////////
$(document).on('change', '#departOff', function () {
currentDate2 = $("#departOff").val();
+ currentDate2 = currentDate2.replace(/-/g, "/");
currentDate2 = new Date(currentDate2);
- currentDate2 = new Date(currentDate2.getUTCFullYear(), currentDate2.getUTCMonth(),currentDate2.getUTCDate());
- currentDate2.setDate(currentDate2.getDate());
+
if($("#departOff").val() <= requiredDate){
$("#departOff").val(minDays);
}