mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-21 21:04: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;
|
namespace Icinga\Web\View;
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Date\DateFormatter;
|
||||||
use Icinga\Util\Format;
|
use Icinga\Util\Format;
|
||||||
|
|
||||||
$this->addHelperFunction('format', function () {
|
$this->addHelperFunction('format', function () {
|
||||||
return Format::getInstance();
|
return Format::getInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->addHelperFunction('timeAgo', function ($timestamp) {
|
$this->addHelperFunction('timeAgo', function ($time, $timeOnly = false) {
|
||||||
if (! $timestamp) {
|
if (! $time) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<span class="time-ago" title="%s">%s</span>',
|
'<span class="time-ago" title="%s">%s</span>',
|
||||||
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
date('Y-m-d H:i:s', $time), // TODO: internationalized format
|
||||||
Format::timeAgo($timestamp)
|
DateFormatter::timeAgo($time, $timeOnly)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->addHelperFunction('timeSince', function ($timestamp) {
|
$this->addHelperFunction('timeSince', function ($time, $timeOnly = false) {
|
||||||
if (! $timestamp) {
|
if (! $time) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<span class="time-since" title="%s">%s</span>',
|
'<span class="time-since" title="%s">%s</span>',
|
||||||
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
date('Y-m-d H:i:s', $time), // TODO: internationalized format
|
||||||
Format::timeSince($timestamp)
|
DateFormatter::timeSince($time, $timeOnly)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->addHelperFunction('timeUntil', function ($timestamp) {
|
$this->addHelperFunction('timeUntil', function ($time, $timeOnly = false) {
|
||||||
if (! $timestamp) {
|
if (! $time) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<span class="time-until" title="%s">%s</span>',
|
'<span class="time-until" title="%s">%s</span>',
|
||||||
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
|
date('Y-m-d H:i:s', $time), // TODO: internationalized format
|
||||||
Format::timeUntil($timestamp)
|
DateFormatter::timeUntil($time, $timeOnly)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user