Overwritten Date.prototype.setFullYear ingnores parameters
Brought to you by:
mishoo
Hi,
many thanks for the great calendar!
I have stumbled upon one problem however:
the script overwrites the original Date.prototype.setFullYear function. However, the original function also allows for setting the month and date, which the overwritten function does not. This caused some conflicts with other code in my applications.
So the original spec defines this function:
Date.setFullYear(yearVal [, monthVal, dayVal]).
Nothing I can't workaround though.
Thanks.
Reinier
I just stumbled onto the same thing. I wish the Date object wasn't exploited that way. This really has a negative impact on the rest of my project. How did you workaround it? I did this:
Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y, month, day) {
var d = new Date(this);
d.__msh_oldSetFullYear(y, month, day);
if (d.getMonth() != this.getMonth())
this.setDate(28);
this.__msh_oldSetFullYear(y, month, day);
};