Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-40246

Date Picker inverts date and month when using Japanese with Chrome

    XMLWordPrintable

Details

    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.

      1. Shutdown JIRA
      2. Backup Calendar.js (<JIRA_INSTALL_DIR>/atlassian-jira/includes/lib/calendar/Calendar.js)
      3. 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();
        }
        
      4. Start JIRA

      Attachments

        1. DatePicker.jpg
          DatePicker.jpg
          81 kB
        2. DatePicker2.jpg
          DatePicker2.jpg
          99 kB

        Activity

          People

            ohernandez@atlassian.com Oswaldo Hernandez (Inactive)
            mnakagawa Mai Nakagawa (Inactive)
            Votes:
            9 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: