stefangabos/Zebra_Datepicker

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

Closed this issue · 6 comments

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/

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

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

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

Works great, thanks!

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

done