Show time of last report and time since

This commit is contained in:
Keir Nellyer 2016-06-27 18:15:41 +01:00
parent 48a2d0d304
commit 128f6af83d
2 changed files with 22 additions and 2 deletions

View File

@ -39,6 +39,25 @@
return $this->messages;
}
/**
* @return Message
*/
public function getLatestMessage()
{
/** @var Message $latest */
$latest = null;
foreach ($this->messages as $message)
{
if ($latest == null || $latest->getTimestamp()->diff($message->getTimestamp()) > 0) // todo test
{
$latest = $message;
}
}
return $latest;
}
/**
* @return User[]
*/

View File

@ -398,7 +398,8 @@ if ($validid)
$displayAmount = $expanded || $messageCount <= collapsedMessageCount ? $messageCount : collapsedMessageCount;
// TODO Calculate time since last report
//$age = approximateHumanInterval($dateTime->diff(new DateTime('now', $dateTime->getTimezone())));
$lastReportTime = $snapshot->getLatestMessage()->getTimestamp();
$age = approximateHumanInterval($lastReportTime->diff(new DateTime('now', $lastReportTime->getTimezone())));
// Put all reporter usernames in array for easy access later
$reporterUsernames = array();
@ -451,7 +452,7 @@ if ($validid)
<div class="row">
<div class="col-lg-12">
<i class="fa fa-clock-o fa-fw"></i>
<span class="label label-pill label-default" title="<?= /*$dateTime->format('Y/m/d H:i:s T')*/'' ?>"><?= /*$age . ' old'*/'' ?></span>
<span class="label label-pill label-default" title="Last Report: <?= $lastReportTime->format('Y/m/d H:i:s T') ?>"><?= $age . ' ago' ?></span>
<br>
<i class="fa fa-user-plus fa-fw"></i>