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;
|
|
|
|
|
|
|
|
use Icinga\Web\Url;
|
|
|
|
use Icinga\Util\Format;
|
|
|
|
|
|
|
|
$this->addHelperFunction('format', function () {
|
|
|
|
return Format::getInstance();
|
|
|
|
});
|
|
|
|
|
2015-04-10 09:56:39 +02:00
|
|
|
$this->addHelperFunction('timeAgo', function ($timestamp) {
|
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>',
|
2014-06-20 12:28:55 +02:00
|
|
|
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
2015-04-10 09:56:39 +02:00
|
|
|
Format::timeAgo($timestamp)
|
2014-06-20 12:28:55 +02:00
|
|
|
);
|
2014-03-17 17:14:16 +01:00
|
|
|
});
|
|
|
|
|
2015-04-10 09:56:39 +02:00
|
|
|
$this->addHelperFunction('timeSince', function ($timestamp) {
|
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>',
|
2014-06-20 12:28:55 +02:00
|
|
|
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
2015-04-10 09:56:39 +02:00
|
|
|
Format::timeSince($timestamp)
|
2014-06-20 12:28:55 +02:00
|
|
|
);
|
2014-05-29 11:26:02 +02:00
|
|
|
});
|
|
|
|
|
2014-05-29 12:38:59 +02:00
|
|
|
$this->addHelperFunction('timeUntil', function ($timestamp) {
|
2014-03-17 17:14:16 +01:00
|
|
|
if (! $timestamp) 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>',
|
2014-06-20 12:28:55 +02:00
|
|
|
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
|
|
|
Format::timeUntil($timestamp)
|
|
|
|
);
|
2014-03-17 17:14:16 +01:00
|
|
|
});
|
|
|
|
|
2014-09-23 11:36:09 +02:00
|
|
|
$this->addHelperFunction('dateTimeRenderer', function ($dateTimeOrTimestamp, $future = false) {
|
|
|
|
return DateTimeRenderer::create($dateTimeOrTimestamp, $future);
|
|
|
|
});
|