Details
-
Bug
-
Resolution: Fixed
-
Low
-
6.3.6, 6.4-OD-16
-
6.03
-
Description
Symptom
Date Picker inverts date and month when using Japanese and when using Google Chrome during 1st~12th of each month
Cause
JIRA sets localised dateStr in Calendar.js file, while it should be RFC2822 / IETF date syntax in English.
This is the related code block in Calendar.js (<JIRA_INSTALL_DIR>/atlassian-jira/includes/lib/calendar/Calendar.js):
// try to parse the current date/time in ISO8601 format if (this.dateStr) { this.date = new Date(this.dateStr); } // fall back to date/time in browser time zone if necessary if (!this.date || isNaN(this.date)) { this.date = new Date(); }
- In the following condition, the string stored in this.dateStr variable is like something like "金, 12 6 2015 13:02:31 " (Friday June 12th) and Chrome wrongly parses the this.dateStr variable as December 6th when new Date(this.dateStr) is called:
- Language is Japanese
- Browser is Chrome
- Date of months is either of 1st~12th
- Other than the above condition, although the string stored in this.dateStr is localised, the browser returns 'Invalid Date' when new Date(this.dateStr) is called. So new Date() is called and it stores the correct date in this.date variable.
Workaround
Note that modifying source code is out of Atlassian Support scope. Please do it at your own risk.
- Shutdown JIRA
- Backup Calendar.js (<JIRA_INSTALL_DIR>/atlassian-jira/includes/lib/calendar/Calendar.js)
- Modify the above code block in Calendar.js so that new Date(this.dateStr) can be called only when this.dateStr is in English. For example:
var isEnglish = function(dateStr) { matcher = dateStr.toString().match(/^([A-Z][a-z]{2})/); if (!matcher) return false; if (["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].indexOf(matcher[1]) == -1) return false; return true; } // try to parse the current date/time in ISO8601 format if (this.dateStr && isEnglish(this.dateStr)) { this.date = new Date(this.dateStr); } // fall back to date/time in browser time zone if necessary if (!this.date || isNaN(this.date)) { this.date = new Date(); }
- Start JIRA