From 415bbfb121638f731f335fddf2ba92e7aa898776 Mon Sep 17 00:00:00 2001 From: yuanhao0230 <13303461281@189.cn> Date: Sat, 23 May 2020 17:28:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=E5=87=BD=E6=95=B0human?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=87=E6=9C=9F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/lang/zh-cn.php | 8 ++++++++ extend/fast/Date.php | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index d9ad4c23e..9aee9d6bf 100644 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -99,6 +99,14 @@ return [ '%d month%s ago' => '%d月前', '%d year%s ago' => '%d年前', // + '%d second%s after' => '%d秒后', + '%d minute%s after' => '%d分钟后', + '%d hour%s after' => '%d小时后', + '%d day%s after' => '%d天后', + '%d week%s after' => '%d周后', + '%d month%s after' => '%d月后', + '%d year%s after' => '%d年后', + // 'Set to normal' => '设为正常', 'Set to hidden' => '设为隐藏', 'Invalid parameters' => '未知参数', diff --git a/extend/fast/Date.php b/extend/fast/Date.php index 8e84d0448..ed73e43fd 100644 --- a/extend/fast/Date.php +++ b/extend/fast/Date.php @@ -133,7 +133,8 @@ class Date */ public static function human($remote, $local = null) { - $timediff = (is_null($local) || $local ? time() : $local) - $remote; + $type = ($remote > $local) ? 'after' : 'ago'; + $timediff = abs((is_null($local) || $local ? time() : $local) - $remote); $chunks = array( array(60 * 60 * 24 * 365, 'year'), array(60 * 60 * 24 * 30, 'month'), @@ -153,7 +154,7 @@ class Date break; } } - return __("%d {$name}%s ago", $count, ($count > 1 ? 's' : '')); + return __("%d {$name}%s {$type}", $count, ($count > 1 ? 's' : '')); } /** -- Gitee