longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

What is it for? #415

Closed kl23 closed 6 years ago

kl23 commented 6 years ago

I guess it should be defaults[0] = defaults[0].replace(/(\d+)(th|rd|nd|st)/, '$1'); ??

https://github.com/longbill/jquery-date-range-picker/blob/23cbf1fca097a9665e310a1054081f5cb8e8bd72/src/jquery.daterangepicker.js#L1319

holtkamp commented 6 years ago

Why do you think that? Do you have an example? If so: can you provide it in a Pull Request?

kl23 commented 6 years ago

by the regular expression, it seems that it aims at removing the ordinal suffixes after a number. e.g. 1st 2nd 3rd 4th ...

I am not really sure about it. Any advise?

holtkamp commented 6 years ago

by the regular expression, it seems that it aims at removing the ordinal suffixes after a number. e.g. 1st 2nd 3rd 4th ...

indeed, but what values (defaults) could be used as input? No idea how this part works and whether "rd" would be a string that is used...

Also see https://github.com/longbill/jquery-date-range-picker/issues/6

kl23 commented 6 years ago

After some more study on the code, I believe that it purposely support Do in the format string such that, for example: DDo MMM YYYY will be temporarily stored in ___format and is replaced to DD MMM YYYY. It then remove all possible ordinal suffixes, i.e. st, nd, rd and th, so that the format string works as normal cases.

holtkamp commented 6 years ago

Mm, ok, any more information in this Do formatting part? Can't find anything quickly...

http://www.mattkruse.com/javascript/date/

I am hesitant in changing / fixing stuff that we do not completely understand and is not broken.

kl23 commented 6 years ago

@holtkamp you're right, just keep it as an information in case it breaks after years.

and, information for who may visit here. Do formating is supported in moment https://momentjs.com/docs/

holtkamp commented 6 years ago

Thanks for understanding! Closing issue