From 3a95644848ecf3729df274dbd84b266283e9d204 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Sun, 14 Oct 2018 22:57:44 +0200 Subject: [PATCH] Add Support for relativeDateTime in future + update Admin user waiting for deleting table header --- mod/admin.php | 2 +- src/Util/Temporal.php | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index d0e8ab0e38..b02db73bdd 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1922,7 +1922,7 @@ function admin_page_users(App $a) '$h_users' => L10n::t('Users'), '$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, '$order_users' => $order, '$order_direction_users' => $order_direction, diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 46bd8bba50..696721e458 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -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])); -- 2.39.5