perf: 7天内显示时间m-d H:i

This commit is contained in:
kuaifan 2022-05-21 19:21:31 +08:00
parent b749426389
commit d0d6b8ce97

View File

@ -103,10 +103,13 @@
*/
formatTime(date) {
let time = $A.Date(date, true),
now = $A.Time(),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
if ($A.formatDate('Ymd', now) === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)
} else if ($A.formatDate('Y') === $A.formatDate('Y', time)) {
} else if (now - time < 86400 * 7) {
string = $A.formatDate('m-d H:i', time)
} else if ($A.formatDate('Y', now) === $A.formatDate('Y', time)) {
string = $A.formatDate('m-d', time)
} else {
string = $A.formatDate('Y-m-d', time)