Twipped / Kalendae

A javascript date picker that just works.
MIT License
1.99k stars 285 forks source link

After Selecting A Date, Restoring Focus On Field Causes Year To Be 0000 #206

Open wisam22 opened 7 years ago

wisam22 commented 7 years ago

Love the library, very convenient solution to a common problem. However, I keep encountering the issue where after selecting a date, trying to reopen the date picker to change the date causes the year to break and always show as "0000".

wisam22 commented 7 years ago

Turns out this issue was specifically happening when I included a comma in my "format" parameter. I've decided to use a different format for the time being. I was using: MMM DD, YYYY

Ni03 commented 7 years ago

Solve problem when we change a value of parseSplitDelimiter option of the plugin with ' - ' (Exactly Same Space Comma Space). There is an issue with regex. When we try to set Mode as range & Format as MMM DD, YYYY (especially having comma) then split 2 dates string with 4 dates Ex Consider selected dates are Apr 1, 2017 - May 19, 2017. when try to reopen calendar then split string with a regex /,\s*|\s+-\s+/ (that is parseSplitDelimiter option) then we get array [ "Apr 1" , "2017" , "May 19" , "2017" ]

there are 4 dates, generate because of the wrong regex. like, [ Sat Apr 01 0 12:00:00 GMT+0530 (IST), Fri Jan 20 17 12:00:00 GMT+0530 (IST), Fri May 19 0 12:00:00 GMT+0530 (IST),
Fri Jan 20 17 12:00:00 GMT+0530 (IST) ]

that's why shows Apr & May month with 0000 years. When we change parseSplitDelimiter option with ' - ' String split with correct two dates. [ "Apr 1, 2017" , "May 19, 2017" ] then generate only two correct dates. like, [ Sat Apr 01 2017 12:00:00 GMT+0530 (IST), Fri May 19 2017 12:00:00 GMT+0530 (IST) ]

This is a temporary solution, need to find correct regex.