fix #258 reopen data_with_log_小兒(日)

This commit is contained in:
Cindy Chang
2024-06-14 14:00:29 +08:00
parent d47b17f575
commit 8c09e8ae40

View File

@@ -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'; // 月
}