From 80db5cf3c98423097f8c46a4053914576aba1fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 31 Oct 2014 02:19:33 +0100 Subject: [PATCH] Add date to message if they are from a previous day --- acptemplate/__messageLogTable.tpl | 2 +- acptemplate/messageLogDownload.tpl | 2 +- file/lib/data/message/Message.class.php | 4 +++- language/de.xml | 3 +++ language/en.xml | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/acptemplate/__messageLogTable.tpl b/acptemplate/__messageLogTable.tpl index 157f124..821cbb6 100644 --- a/acptemplate/__messageLogTable.tpl +++ b/acptemplate/__messageLogTable.tpl @@ -13,7 +13,7 @@ {foreach from=$messages item="message"} {$message->messageID} - {$message->time|date:"H:i:s"} + {$message->time|date:"chat.global.timeFormat"}

{@$message->getUserProfile()->getAvatar()->getImageTag(24)}

{$message->username} {@$message->getFormattedMessage("text/simplified-html")} diff --git a/acptemplate/messageLogDownload.tpl b/acptemplate/messageLogDownload.tpl index cbfa157..dd12fcc 100644 --- a/acptemplate/messageLogDownload.tpl +++ b/acptemplate/messageLogDownload.tpl @@ -1,5 +1,5 @@ {foreach from=$messages item=$rawMessage}{* *}{assign var=message value=$rawMessage->jsonify(true)}{* - *}({$message['time']|date:'H:i:s'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]} + *}({$message['time']|date:'chat.global.timeFormat'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]} {/foreach} diff --git a/file/lib/data/message/Message.class.php b/file/lib/data/message/Message.class.php index f97f794..ccceb0c 100644 --- a/file/lib/data/message/Message.class.php +++ b/file/lib/data/message/Message.class.php @@ -153,10 +153,12 @@ public function jsonify($raw = false) { break; } + $time = \wcf\util\DateUtil::getDateTimeByTimestamp($this->time); + $startOfDay = new \DateTime('today', WCF::getUser()->getTimezone()); $array = array( 'formattedUsername' => $this->getUsername(true), 'formattedMessage' => $this->getFormattedMessage('text/html'), - 'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'), + 'formattedTime' => ($time->getTimestamp() < $startOfDay->getTimestamp() ? \wcf\util\DateUtil::format($time, 'chat.global.dateFormat').' ' : '').\wcf\util\DateUtil::format($time, 'chat.global.timeFormat'), 'separator' => $separator, 'message' => $this->getFormattedMessage('text/plain'), 'sender' => (int) $this->sender, diff --git a/language/de.xml b/language/de.xml index 7a23b6e..2b76555 100644 --- a/language/de.xml +++ b/language/de.xml @@ -193,6 +193,9 @@ Probieren Sie, den Chat neu zu laden