1
0
Fork 0

Add Support for relativeDateTime in future + update Admin user waiting for deleting table header

This commit is contained in:
Jonny Tischbein 2018-10-14 22:57:44 +02:00
commit 3a95644848
2 changed files with 14 additions and 3 deletions

View file

@ -294,12 +294,18 @@ class Temporal
return L10n::t('never');
}
$isfuture = false;
$etime = time() - $abs;
if ($etime < 1) {
if ($etime < 1 && $etime >= 0) {
return L10n::t('less than a second ago');
}
if ($etime < 0){
$etime = -$etime;
$isfuture = true;
}
$a = [12 * 30 * 24 * 60 * 60 => [L10n::t('year'), L10n::t('years')],
30 * 24 * 60 * 60 => [L10n::t('month'), L10n::t('months')],
7 * 24 * 60 * 60 => [L10n::t('week'), L10n::t('weeks')],
@ -315,7 +321,12 @@ class Temporal
$r = round($d);
// translators - e.g. 22 hours ago, 1 minute ago
if (!$format) {
$format = L10n::t('%1$d %2$s ago');
if($isfuture){
$format = L10n::t('in %1$d %2$s');
}
else {
$format = L10n::t('%1$d %2$s ago');
}
}
return sprintf($format, $r, (($r == 1) ? $str[0] : $str[1]));