stefangabos / Zebra_Datepicker

A super-lightweight, highly configurable, cross-browser date time picker jQuery plugin
https://stefangabos.github.io/Zebra_Datepicker/
Other
398 stars 183 forks source link

months_abbr and days_abbr not used in check_date, does not cope with full stops (i.e. dutch abbreviations) #161

Closed nathangreaves closed 4 years ago

nathangreaves commented 4 years ago

When using a browser with culture 'nl' (dutch) and a format that contains either 'M' (abbreviated day) or 'D' (abbreviated month), there are 2 issues that exist within the check_date function (which is used to parse a date string against the specified date format, for example when calling the set_date function). This is causing issues when programatically setting the date, or when passing dates into the 'direction' parameter to specify start date/end date of the datepicker.

The first issue is that in the dutch locale, abbreviated months are represented with a full stop. (i.e. ma. mrt. 11, 2030 which would in the UK be Mon Mar 11 2030). The regex used for 'M' in check_date is [a-z]{3} which therefore does not match this correctly. The second issue is that if you have specified months_abbr (i.e. in dutch the full month 'March' is 'maart' but the abbreviation is 'mrt.') the code in check_date does not use the abbreviations specified in months_abbr and instead takes the first three characters of months, which as you can see will not work in Dutch. The same 2 issues exist for days/days_abbr when the format specifier 'D' is used.

I have created a jsfiddle to demonstrate the issue for multiple different languages: https://jsfiddle.net/wn67e0vh/4/

stefangabos commented 4 years ago

i am working now on a fix and will get back to you later today. thanks for reporting the issue!

nathangreaves commented 4 years ago

Ah, I also have a fix available and was about to link a pull request! I can step off though if you are on it

stefangabos commented 4 years ago

I've done some changes, please have a look and let me know if it works as expected

nathangreaves commented 4 years ago

Works great, thanks!

nathangreaves commented 4 years ago

@stefangabos Please could I request a release with the included changes so that I can update via npm?

stefangabos commented 4 years ago

done