DatePicker: bug in parsing date in 2-digits year format for February 29

2 posts, 0 answers
  1. David Rainton
    David Rainton avatar
    6 posts
    Member since:
    Mar 2004

    Posted 21 Nov 2014 Link to this post

    It looks like there is a bug in parsing of dates in 2-digits year format ("yy") that affects keyboard input in the DatePicker widget. I created a simple example of the issue at To reproduce the issue change string value to '2/29/2013' with keyboard (don't use popup calendar!). Click anywhere outside of the widget. Surprisingly the value is changed to '2/29/2020'. This is a quite unexpected behavior.

    It looks like the reason is that I configured the widget to support both 4-digits and 2-digits year formats (specifically "M/d/yyyy" and "M/d/yy"). Obviously 2013 is not a leap year and there is no "February 29, 2013" but "February 29, 2020" is a valid date!

    After some investigation I found that the issue seems to be in the kendo.parseDate: 

    kendo.parseDate('2/29/2013', "M/d/yy")
    kendo.parseDate('2/29/2013', ["M/d/yyyy", "M/d/yy"])

    both return date "February 29, 2020" instead of null.

    Is there a way to allow both 4- and 2-digits year formats in a DatePicker but avoid such an issue with "February 29"?
  2. Georgi Krustev
    Georgi Krustev avatar
    3725 posts

    Posted 25 Nov 2014 Link to this post

    Hello David,

    Currently, the kendo.parseDate will successfully match the "20" string value from the provided year and thus will produce the dates shown in the example. For now, you will need to allow only dates with 4 digits, because there is no feasible way to avoid this behavior.

    I've logged a Github issue for further investigation and we will try to find a proper solution of this discrepancy.

    Best regards,
    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top