Uploaded image for project: '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

      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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 36 weeks ago