joomla/joomla-cms — pull request #4480 by purplebeanie (2014-10-08 09:02:40+00:00)
Title: Remove definition of setFullYear from calendar javascript

As per issue #4479 calendar.js and calendar-uncompressed.js overwrite the standard Javascript setFullYear(year,month,day) function with setFullYear(year).

This means scripts that use javascript's setFullYear function on a page that has the standard datetimepicker loaded may not function correctly as parameters other than year are ignored.

#### Testing instructions

Before applying this patch make sure the calendar.js is being loaded.

1. Easiest way to do this is to add `Jhtml::_('behavior.calendar');` to your active template index.php file.
2. Open your site and then use Chrome developer tools to run the following at the JS console. (thanks @Fedik for picking up my previous mistake)

```
// define date var:
var date = new Date();
// check the date:
console.log('Original: ' + date.toLocaleDateString());
// try change the date
date.setFullYear(2014,11,25);
// check result
console.log('Changed: ' + date.toLocaleDateString());
```

The changed will be the same as the Original as only the year will have been updated.

**Now test the actual patch.**

3. Apply the patch and refresh the page.
4. Using the Javascript console re-run the code from before. This time the changed date should be Christmas day.

#### Question? Will anything break?

All I have done is remove the offending setFullYear function from the calendar.js and calendar-uncompressed.js. Is this safe? The date pickers in the back end still worked correctly after I made this change, so I don't think it breaks anything obvious.

I checked Jalili calendar addon and they didn't actually define setFullYear themselves. Rather it defined `_calSetFullYear` so possibly this isn't going to break anything. Can someone with more historical knowledge advise?

Cheers,
Eric.