From 8c09e8ae40dd059786dd4f632a5a4f8367537bf0 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Fri, 14 Jun 2024 14:00:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#258=20reopen=20data=5Fwith=5Flog=5F?= =?UTF-8?q?=E5=B0=8F=E5=85=92=EF=BC=88=E6=97=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/timeLabel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/module/timeLabel.js b/src/module/timeLabel.js index e2860cb..25b39e8 100644 --- a/src/module/timeLabel.js +++ b/src/module/timeLabel.js @@ -263,7 +263,9 @@ export function dateLabel(date, maxDate, minDate) { * @returns {string} - The suitable time format string. */ export const setTimeStringFormatBaseOnTimeDifference = (minTimeStamp, maxTimeStamp) => { - const timeDifferenceInSeconds = (minTimeStamp - maxTimeStamp) / 1000; + const laterDate = new Date(maxTimeStamp); + const earlyDate = new Date(minTimeStamp); + const timeDifferenceInSeconds = (laterDate - earlyDate) / 1000; let dateFormat; if (timeDifferenceInSeconds < 60) { @@ -273,7 +275,7 @@ export const setTimeStringFormatBaseOnTimeDifference = (minTimeStamp, maxTimeSta } else if (timeDifferenceInSeconds < 86400) { // 86400 秒 = 24 小時 dateFormat = 'MM/DD HH:mm'; // 小時 } else if (timeDifferenceInSeconds < 2592000) { // 2592000 秒 = 30 天 - dateFormat = 'MM/DD'; // 天 + dateFormat = 'YYYY/MM/DD'; // 天 } else { dateFormat = 'YYYY/MM'; // 月 }