icingaweb2/library/Icinga/Web/View/helpers/format.php

41 lines
1.2 KiB
PHP
Raw Normal View History

<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
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) {
return sprintf(
'<span class="time-ago" title="%s">%s</span>',
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
2015-04-10 09:56:39 +02:00
Format::timeAgo($timestamp)
);
});
2015-04-10 09:56:39 +02:00
$this->addHelperFunction('timeSince', function ($timestamp) {
return sprintf(
'<span class="time-since" title="%s">%s</span>',
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
2015-04-10 09:56:39 +02:00
Format::timeSince($timestamp)
);
});
$this->addHelperFunction('timeUntil', function ($timestamp) {
if (! $timestamp) return '';
return sprintf(
'<span class="time-until" title="%s">%s</span>',
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
Format::timeUntil($timestamp)
);
});
$this->addHelperFunction('dateTimeRenderer', function ($dateTimeOrTimestamp, $future = false) {
return DateTimeRenderer::create($dateTimeOrTimestamp, $future);
});