The error (or function, but I hope it is not) was introduced in version 1.8.4 of jQuery UI (hence the demo posted by D Hoerster works as it uses version 1.8.2). The source of this is line 8384 in this version posted by Google. This is the part covering the generation of the actual datepicker HTML file. It is inside the cycle, repeating every month to be drawn. He reads
var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
Now drawmonth/year is the current month that is looming (duh), so itโs pretty obvious whatโs happening. As a result, your stated problem is that if you select 17th place in one month, selectedDate will be set on the 17th of each month when you iterate over them and they will be highlighted. Judging by the name of the variable ( selectedDate ) and its semantic value, you should instead indicate
var selectedDate = this._daylightSavingAdjust(new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay));
The funny thing is that this error was also present in version 1.8.2, but the code that makes the selection did not use it in the previous version. In 1.8.2, highlighting the current date was performed as (on line 8446):
(printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') +
and looking at the code, it is clear that it should be the same as in version 1.8.4 (use selectedDate instead of currentDate ):
(printDate.getTime() == selectedDate.getTime() ? ' ui-state-active' : '') +
So itโs strange that no more errors occur, since
selectedDate seems to be erroneous and is used in several places. (And the fact that nothing happened in the previous version, despite the fact that an incorrect variable was used to calculate the current date). I have looked at this code for too long, so I donโt know if I am right or wrong. Nevertheless, this should be a good basis for people who want to continue the study and possibly report a mistake. I will do it myself in the end when I get the time (and my sanity)