Calendar setDate broken with specific dateFormat and last day of month

Hi,

Just downloaded Dhtmlx Calendar 6.0 (using 5.x before), and there’s a big issue with the Calendar.setDate method when a dateFormat like “%d/%m/%y” is used.

To reproduce the issue :

  • set the dateFormat to “%d/%m/%y”
  • create the calendar as a popup, and on the click event, call setDate with December 31 2019 date, that is to say “31/12/19” according to the dateFormat property
  • notice that the date on the UI is “corrected” to 01/12/2019 (December 1 2019).

Same thing happens with October 31, etc.

I rea the source code, it seems that setDate, setMonth, etc. are called on a Date object in the order of the %xx tokens in the dateFormat property. However, doing this is wrong, since when trying to set a date to December 31, with a “%d/%m/%y” dateFormat, we call setDate(31) before setMonth(11). Try doing this in a javascript console, you will see the Date object behaving wrong.

By the way, there’s no issue with 5.x release.

Thank you for your feedback. The problem with the dhtmlxCalendar 6.0 setValue() method is confirmed. We’ll fix in the nearest update.

1 Like