lib: Add timeAgo to views

refs #6778
This commit is contained in:
Eric Lippmann 2015-04-10 09:56:39 +02:00
parent 7f73c6ae29
commit 3ec6caa15b
1 changed files with 16 additions and 8 deletions

View File

@ -10,6 +10,14 @@ $this->addHelperFunction('format', function () {
return Format::getInstance();
});
$this->addHelperFunction('timeAgo', function ($timestamp) {
return sprintf(
'<span class="timeAgo" title="%s">%s</span>',
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
Format::timeAgo($timestamp)
);
});
$this->addHelperFunction('timeSince', function ($timestamp) {
return sprintf(
'<span class="timesince" title="%s">%s</span>',
@ -18,14 +26,6 @@ $this->addHelperFunction('timeSince', function ($timestamp) {
);
});
$this->addHelperFunction('prefixedTimeSince', function ($timestamp, $ucfirst = false) {
return sprintf(
'<span class="timesince" title="%s">%s</span>',
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
Format::prefixedTimeSince($timestamp, $ucfirst)
);
});
$this->addHelperFunction('timeUntil', function ($timestamp) {
if (! $timestamp) return '';
return sprintf(
@ -35,6 +35,14 @@ $this->addHelperFunction('timeUntil', function ($timestamp) {
);
});
$this->addHelperFunction('prefixedTimeSince', function ($timestamp, $ucfirst = false) {
return sprintf(
'<span class="timesince" title="%s">%s</span>',
date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
Format::prefixedTimeSince($timestamp, $ucfirst)
);
});
$this->addHelperFunction('prefixedTimeUntil', function ($timestamp, $ucfirst = false) {
if (! $timestamp) return '';
return sprintf(