2014-03-17 17:14:16 +01:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-03-17 17:14:16 +01:00
|
|
|
|
|
|
|
namespace Icinga\Web\View;
|
|
|
|
|
2015-05-19 09:56:20 +02:00
|
|
|
use Icinga\Date\DateFormatter;
|
2014-03-17 17:14:16 +01:00
|
|
|
use Icinga\Util\Format;
|
|
|
|
|
|
|
|
$this->addHelperFunction('format', function () {
|
|
|
|
return Format::getInstance();
|
|
|
|
});
|
|
|
|
|
2015-05-19 09:56:20 +02:00
|
|
|
$this->addHelperFunction('timeAgo', function ($time, $timeOnly = false) {
|
|
|
|
if (! $time) {
|
2015-05-18 14:40:55 +02:00
|
|
|
return '';
|
|
|
|
}
|
2014-06-20 12:28:55 +02:00
|
|
|
return sprintf(
|
2015-04-10 14:19:08 +02:00
|
|
|
'<span class="time-ago" title="%s">%s</span>',
|
2015-05-19 10:04:17 +02:00
|
|
|
DateFormatter::formatDate($time),
|
2015-05-19 09:56:20 +02:00
|
|
|
DateFormatter::timeAgo($time, $timeOnly)
|
2014-06-20 12:28:55 +02:00
|
|
|
);
|
2014-03-17 17:14:16 +01:00
|
|
|
});
|
|
|
|
|
2015-05-19 09:56:20 +02:00
|
|
|
$this->addHelperFunction('timeSince', function ($time, $timeOnly = false) {
|
|
|
|
if (! $time) {
|
2015-05-18 14:40:55 +02:00
|
|
|
return '';
|
|
|
|
}
|
2014-06-20 12:28:55 +02:00
|
|
|
return sprintf(
|
2015-04-10 14:19:08 +02:00
|
|
|
'<span class="time-since" title="%s">%s</span>',
|
2015-05-19 10:04:17 +02:00
|
|
|
DateFormatter::formatDate($time),
|
2015-05-19 09:56:20 +02:00
|
|
|
DateFormatter::timeSince($time, $timeOnly)
|
2014-06-20 12:28:55 +02:00
|
|
|
);
|
2014-05-29 11:26:02 +02:00
|
|
|
});
|
|
|
|
|
2015-05-19 09:56:20 +02:00
|
|
|
$this->addHelperFunction('timeUntil', function ($time, $timeOnly = false) {
|
|
|
|
if (! $time) {
|
2015-05-18 14:40:55 +02:00
|
|
|
return '';
|
|
|
|
}
|
2014-06-20 12:28:55 +02:00
|
|
|
return sprintf(
|
2015-04-10 14:19:08 +02:00
|
|
|
'<span class="time-until" title="%s">%s</span>',
|
2015-05-19 10:04:17 +02:00
|
|
|
DateFormatter::formatDate($time),
|
2015-05-19 09:56:20 +02:00
|
|
|
DateFormatter::timeUntil($time, $timeOnly)
|
2014-06-20 12:28:55 +02:00
|
|
|
);
|
2014-03-17 17:14:16 +01:00
|
|
|
});
|