mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-20 20:34:25 +02:00
Use DateFormatter's format functions in the format view helper
refs #6778
This commit is contained in:
parent
bf8c4f1e9d
commit
9477fdcea4
@ -3,43 +3,43 @@
|
||||
|
||||
namespace Icinga\Web\View;
|
||||
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Date\DateFormatter;
|
||||
use Icinga\Util\Format;
|
||||
|
||||
$this->addHelperFunction('format', function () {
|
||||
return Format::getInstance();
|
||||
});
|
||||
|
||||
$this->addHelperFunction('timeAgo', function ($timestamp) {
|
||||
if (! $timestamp) {
|
||||
$this->addHelperFunction('timeAgo', function ($time, $timeOnly = false) {
|
||||
if (! $time) {
|
||||
return '';
|
||||
}
|
||||
return sprintf(
|
||||
'<span class="time-ago" title="%s">%s</span>',
|
||||
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
||||
Format::timeAgo($timestamp)
|
||||
date('Y-m-d H:i:s', $time), // TODO: internationalized format
|
||||
DateFormatter::timeAgo($time, $timeOnly)
|
||||
);
|
||||
});
|
||||
|
||||
$this->addHelperFunction('timeSince', function ($timestamp) {
|
||||
if (! $timestamp) {
|
||||
$this->addHelperFunction('timeSince', function ($time, $timeOnly = false) {
|
||||
if (! $time) {
|
||||
return '';
|
||||
}
|
||||
return sprintf(
|
||||
'<span class="time-since" title="%s">%s</span>',
|
||||
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
||||
Format::timeSince($timestamp)
|
||||
date('Y-m-d H:i:s', $time), // TODO: internationalized format
|
||||
DateFormatter::timeSince($time, $timeOnly)
|
||||
);
|
||||
});
|
||||
|
||||
$this->addHelperFunction('timeUntil', function ($timestamp) {
|
||||
if (! $timestamp) {
|
||||
$this->addHelperFunction('timeUntil', function ($time, $timeOnly = false) {
|
||||
if (! $time) {
|
||||
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)
|
||||
date('Y-m-d H:i:s', $time), // TODO: internationalized format
|
||||
DateFormatter::timeUntil($time, $timeOnly)
|
||||
);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user