Use Date.getTime instead of relaying on implicit conversion
Otherwise, fucking IntelliJ does not shut up about imaginary problems.
This commit is contained in:
parent
28adeb38fc
commit
33a1f0f4e2
|
@ -3,7 +3,7 @@
|
|||
|
||||
function updateDepartureDate(arrivalDateField) {
|
||||
const arrivalDate = new Date(arrivalDateField.value);
|
||||
if (isNaN(arrivalDate)) {
|
||||
if (isNaN(arrivalDate.getTime())) {
|
||||
return;
|
||||
}
|
||||
const departureDateField = document.querySelector('[name="departure_date"]');
|
||||
|
@ -17,7 +17,8 @@
|
|||
|
||||
departureDateField.setAttribute('min', minDate);
|
||||
const departureDate = new Date(departureDateField.value);
|
||||
if (isNaN(departureDate) || departureDate < arrivalDate) {
|
||||
const validDepartureDate = !isNaN(departureDate.getTime())
|
||||
if (!validDepartureDate || departureDate < arrivalDate) {
|
||||
departureDateField.value = minDate;
|
||||
}
|
||||
|
||||
|
@ -26,7 +27,7 @@
|
|||
arrivalDate.setUTCDate(arrivalDate.getUTCDate() + maxNights - minNights);
|
||||
const maxDate = formatDate(arrivalDate);
|
||||
departureDateField.setAttribute('max', maxDate);
|
||||
if (!isNaN(departureDate) && departureDate >= arrivalDate) {
|
||||
if (validDepartureDate && departureDate >= arrivalDate) {
|
||||
departureDateField.value = maxDate;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue