PUBLIC - Liferay Portal Community Edition
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-42499

Chat Portlet - message display time shows "11:xx am" as "11:xx pm"

    Details

    • Branch Version/s:
      6.2.x, 6.1.x
    • Backported to Branch:
      Committed
    • Story Points:
      3
    • Fix Priority:
      1
    • Similar Issues:
      Show 5 results 

      Description

      When time reaches 11:xx am, the chat message display time shows "11:xx pm" instead of "11:xx am".

      Steps to reproduce :
      1) Deploy chat portlet into portal
      2) Create 2 users - user1 and user2
      3) Open 2 browsers and log in with each of them
      4) Start chatting at "11:xx am"

      Actual Behavior:
      In the chat box, we will see the display time shows "11:xx pm" instead of "11:xx am"

      Expected Behavior:
      It shows the correct time which is "11:xx am"

      The root cause is that when displaying message, in main.js, _updateMessageWindow function will be called, it uses this to get message :

      					var message = '<p class="blurb ' + cssClass + '">' +
      									'<b class="name">' + Liferay.Util.escapeHTML(userName) + '</b>' +
      									'<i class="date">' + Liferay.Chat.Util.formatTime(entry.createDate) + '</i>' +
      									'<span class="text">' + content + '</span>' +
      								'</p>';
      

      There's following code in formatTime function :

      			formatTime: function(time) {
      				var instance = this;
      
      				time = instance._convertToClientTimestamp(time);
      
      				time = new Date(time);
      
      				var meridian = 'am';
      				var hour = time.getHours();
      				var minute = time.getMinutes();
      
      				if (hour >= 11) {
      					meridian = 'pm';
      				}
      
      				if (hour > 12) {
      					hour -= 12;
      				}
      
      				if (hour === 0) {
      					hour += 12;
      				}
      
      				if (minute < 10) {
      					minute = '0' + minute;
      				}
      
      				return hour + ':' + minute + ' ' + meridian;
      			},
      

      where

      if (hour >= 11) {
      	meridian = 'pm';
      }
      

      should be changed to

      if (hour >= 12) {
      	meridian = 'pm';
      }
      

      Reference : http://en.wikipedia.org/wiki/12-hour_clock

        Activity

        Hide
        Shitian "Shelton" Zhang added a comment -

        This issue is blocked by LPS-42508

        Show
        Shitian "Shelton" Zhang added a comment - This issue is blocked by LPS-42508
        Hide
        shelton.zhang added a comment -

        PASSED Manual Testing following the steps in the description.

        Reproduced on:
        Tomcat 7.0.40 + MySQL 5.5.34. Portal 6.1.30 EE GA3.

        In the chat box, the display time was shown "11:xx pm" instead of "11:xx am".

        Fixed on:
        Tomcat 7.0.40 + MySQL 5.5.34. Portal 6.1.x EE GIT ID: 8cd2a17d81192e70eac2aa0735c106f115718627.
        Plugins 6.1.x EE GIT ID: 5e58467b971262a32c178df17bb88ceb491b1fce.
        Tomcat 7.0.42 + MySQL 5.5.34. Portal ee-6.2.x EE GIT ID: 6ca5ac506ed52369cf72b96267d3ecd58cab87ba.
        Plugins 6.2.x EE GIT ID: 926aebb43e7748513460766548d843258cd0cc17.

        The display time was shown "11:xx am" correctly.

        Show
        shelton.zhang added a comment - PASSED Manual Testing following the steps in the description. Reproduced on: Tomcat 7.0.40 + MySQL 5.5.34. Portal 6.1.30 EE GA3. In the chat box, the display time was shown "11:xx pm" instead of "11:xx am". Fixed on: Tomcat 7.0.40 + MySQL 5.5.34. Portal 6.1.x EE GIT ID: 8cd2a17d81192e70eac2aa0735c106f115718627. Plugins 6.1.x EE GIT ID: 5e58467b971262a32c178df17bb88ceb491b1fce. Tomcat 7.0.42 + MySQL 5.5.34. Portal ee-6.2.x EE GIT ID: 6ca5ac506ed52369cf72b96267d3ecd58cab87ba. Plugins 6.2.x EE GIT ID: 926aebb43e7748513460766548d843258cd0cc17. The display time was shown "11:xx am" correctly.
        Hide
        Joseph Chin added a comment - - edited

        PASSED Manual Testing following the steps in the description.

        Fixed on:
        Tomcat 7.0.42 + MySQL 5.5. Portal 6.2.0 CE GA1. Plugins 6.2.x GIT ID: 36e2838b647f1046836c50cea2423e645e40b5b4.
        Tomcat 7.0.42 + MySQL 5.5. Portal 6.2.10 EE GA1. Plugins ee-6.2.10 GIT ID: 727260035eac25b85cffbe6112f4282162b3de47.

        The display time was shown "11:xx am" correctly.

        Show
        Joseph Chin added a comment - - edited PASSED Manual Testing following the steps in the description. Fixed on: Tomcat 7.0.42 + MySQL 5.5. Portal 6.2.0 CE GA1. Plugins 6.2.x GIT ID: 36e2838b647f1046836c50cea2423e645e40b5b4. Tomcat 7.0.42 + MySQL 5.5. Portal 6.2.10 EE GA1. Plugins ee-6.2.10 GIT ID: 727260035eac25b85cffbe6112f4282162b3de47. The display time was shown "11:xx am" correctly.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 24 weeks, 5 days ago

              Development

                Structure Helper Panel