timeUntil/timeSince: add timestamp hover title

It's sometimes easier to read "full" timestamps.
This commit is contained in:
Thomas Gelf 2014-06-20 12:28:55 +02:00
parent ccb01aa152
commit d504c27641
1 changed files with 20 additions and 12 deletions

View File

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