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
parent 74c5f1f684
commit 3a95644848
2 changed files with 14 additions and 3 deletions

View file

@ -1922,7 +1922,7 @@ function admin_page_users(App $a)
'$h_users' => L10n::t('Users'), '$h_users' => L10n::t('Users'),
'$h_newuser' => L10n::t('New User'), '$h_newuser' => L10n::t('New User'),
'$th_deleted' => [L10n::t('Name'), L10n::t('Email'), L10n::t('Register date'), L10n::t('Last login'), L10n::t('Last item'), L10n::t('Deleted since')], '$th_deleted' => [L10n::t('Name'), L10n::t('Email'), L10n::t('Register date'), L10n::t('Last login'), L10n::t('Last item'), L10n::t('Delete in')],
'$th_users' => $th_users, '$th_users' => $th_users,
'$order_users' => $order, '$order_users' => $order,
'$order_direction_users' => $order_direction, '$order_direction_users' => $order_direction,

View file

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