From 452c9358c997d1a7afd605876cfc7e91d8235663 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Mon, 17 Jun 2024 11:34:13 +0800 Subject: [PATCH] should not be ms but s --- src/module/timeLabel.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/module/timeLabel.js b/src/module/timeLabel.js index 25b39e8..41f766b 100644 --- a/src/module/timeLabel.js +++ b/src/module/timeLabel.js @@ -225,13 +225,13 @@ export function dateLabel(date, maxDate, minDate) { diffMonths += maxDate.getMonth(); // 計算相差的日期,要取整數才能接續下方的邏輯判斷 `diffDays > 0` - // 毫秒 * 秒 * 分鐘 * 小時 = 一天的時間量 - const diffDays = Math.floor(timeDiff / (1000 * 60 * 60 * 24)); + // 秒 * 分鐘 * 小時 = 一天的時間量 + const diffDays = Math.floor(timeDiff / ( 60 * 60 * 24)); // 計算相差的小時、分鐘、秒 - const diffHours = Math.floor(timeDiff / (1000 * 60 * 60)); - const diffMinutes = Math.floor(timeDiff / (1000 * 60)); - const diffSeconds = Math.floor(timeDiff / 1000); + const diffHours = Math.floor(timeDiff / (60 * 60)); + const diffMinutes = Math.floor(timeDiff / 60); + const diffSeconds = Math.floor(timeDiff); // 顯示結果 if (diffMonths > 0) { @@ -265,7 +265,7 @@ export function dateLabel(date, maxDate, minDate) { export const setTimeStringFormatBaseOnTimeDifference = (minTimeStamp, maxTimeStamp) => { const laterDate = new Date(maxTimeStamp); const earlyDate = new Date(minTimeStamp); - const timeDifferenceInSeconds = (laterDate - earlyDate) / 1000; + const timeDifferenceInSeconds = (laterDate - earlyDate); let dateFormat; if (timeDifferenceInSeconds < 60) {