jquery-date-range-picker icon indicating copy to clipboard operation
jquery-date-range-picker copied to clipboard

Fix ordinal suffixes format

Open kl23 opened this issue 6 years ago • 3 comments

update /Do/ format for ordinal suffix "rd"

see #415

kl23 avatar Mar 15 '18 15:03 kl23

Thanks, but what "problem" does it fix? You have an actual usecase where the "rd" is used in a date? Never seen it...

holtkamp avatar Mar 15 '18 15:03 holtkamp

till an hour ago, I supposed that moment claims a format with ordinal suffix an invalid date.

the part below ___format calls getValidDate() which depends on moment but moment accepts the following in its isValid() function and returns true for some weird cases:

  • 3st Mar 2018 (this one is still kinda acceptable)
  • 1xx Mar 2018
  • 222 Mar 2018
  • 5xxworhnou42ntub20485c234c23nrewst Mar 2018 (What?!)

e.g. moment('5xxworhnou42ntub20485c234c23nrewst Mar 2018', 'Do MMM YYYY').toDate() returns a JS date object of 5 Mar 2018

I am not sure how it defines "a valid date" and "a valid date format". according to its doc,

  • Do: Day of month with ordinal

moment already "support" Do format, so removal is theoretically not necessary any more.

___format is either useless (from now), or, if we need a more specific validation, the validating mechanism in getValidDate() may need some changes.

kl23 avatar Mar 16 '18 02:03 kl23

ok, so the best approach seems to be to put this on hold for now. We might even decide to remove the intermediate ___format approach since it is not even needed (anymore)...

holtkamp avatar Mar 16 '18 10:03 holtkamp