amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.02k forks source link

Date picker defaults to 2099 since Jan 1, 2022. #1238

Closed quinncomendant closed 2 years ago

quinncomendant commented 2 years ago

I have a web app using pickadate.js v3.6.4 that was working perfectly for years. Since January 1 of 2022, when initially invoking the picker, it uses a “current” year of 2099 instead of 2022. Last year, it correctly used the year of 2021.

Has anyone else had this issue? Before I dive into the source code to debug, any ideas what to look for? Is there something significant about dates in javascript that makes a difference between 2021 and 2022?

quinncomendant commented 2 years ago

I found the problem: dates were disabled until the year 2099, so pickadate by default opens with the first date that is not disabled.

$('#date').pickadate({
    disable: [
        // > January 1, 2022, and beyond CLOSED to reservations until we decide on our 2022 calendar year.
        { from: [2022, 0, 1], to: [2099, 0, 1] }
    ]
});

The solution is to simply ensure that the current month contains non-disabled dates (i.e., removing the line { from: [2022, 0, 1], to: [2099, 0, 1] } in the above code).