Javascript Date() setFullYear() weired behaviour in JIRA

The calender-lib plugin (/includes/lib/calendar/Calendar.js) overrides the setFullYear() function of core Javascript.
But I need to use the core functionality.
Core functionality : new Date().setFullYear(2020) => returns 1585910850973.
With JIRA instance : new Date().setFullYear(2020) => returns undefined.

How do I revert the functionality back to default behaviour?


Hi, kgund! Have you reported this issue to Atlassian? I have reached the same conclusion as you: Jira overrides the setFullYear function - something that is a critical error for any system that allows plugins to be installed. It e.g means that any JS library that relies on this function will stop working, which includes “de facto” tools like date-fns, and any code that uses this library.

I asked Stack Overflow for help, and found a solution that worked for our case:


setting the following statement on the starting point of our application solved the issue:

Date.prototype.setFullYear = Date.prototype.__msh_oldSetFullYear;

Where Date.prototype.__msh_oldSetFullYear is the native implementation of setFullYear that (luckily) had stored and exposed through a variable by the offending calendar-lib code.

Update 17.06.2019:

This issue has now been confirmed by the Atlassian developer team: