Remove dead code and incorrect unused comments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -99,18 +99,6 @@ export function getTimeLabel(second, fixedNumber = 0) {
|
||||
return second + " sec";
|
||||
}
|
||||
|
||||
/** UNUSED
|
||||
* Converts seconds into a formatted string with time units.
|
||||
* 將秒數轉換成帶有時間單位的格式
|
||||
*
|
||||
* @param {number} second - Total seconds
|
||||
* 總秒數
|
||||
* @param {number} fixedNumber - Number of decimal places
|
||||
* 小數點後幾位
|
||||
* @returns {string} - The formatted time string (e.g., 1 day, 6.8 hrs)
|
||||
* 轉換完的格式(ex: 1 day, 6.8 hrs)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 將秒數轉換成帶有縮寫時間單位的格式
|
||||
* @param {number} second 總秒數
|
||||
@@ -204,55 +192,6 @@ export function followTimeLabel(second, max, fixedNumber = 0) {
|
||||
}
|
||||
|
||||
|
||||
/** UNUSED
|
||||
* 將時間轉換成不同日期單位的格式
|
||||
* @param { string } date 日期
|
||||
* @param { string } maxX 該 data 最大的日期,格式是 timestamp
|
||||
* @param { string } minX 該 data 最小的日期,格式是 timestamp
|
||||
*/
|
||||
export function getDateLabelByMinMaxDate(date, maxDate, minDate) {
|
||||
// 將時間字串轉換為時間物件
|
||||
// new Date(time) 之後不用 getTime(),因為在JavaScript中,
|
||||
// 日期物件是以時間戳記(timestamp)的形式存儲的。當創建一個新的日期物件時,
|
||||
// 它內部會自動轉換時間字串為時間戳記。
|
||||
date = new Date(date);
|
||||
maxDate = new Date(maxDate);
|
||||
minDate = new Date(minDate);
|
||||
|
||||
// 計算時間差距
|
||||
let timeDiff = maxDate - minDate;
|
||||
|
||||
// 計算相差的月份
|
||||
let diffMonths = (maxDate.getFullYear() - minDate.getFullYear()) * 12;
|
||||
diffMonths -= minDate.getMonth();
|
||||
diffMonths += maxDate.getMonth();
|
||||
|
||||
// 計算相差的日期,要取整數才能接續下方的邏輯判斷 `diffDays > 0`
|
||||
// 秒 * 分鐘 * 小時 = 一天的時間量
|
||||
const diffDays = Math.floor(timeDiff / ( 60 * 60 * 24));
|
||||
|
||||
// 計算相差的小時、分鐘、秒
|
||||
const diffHours = Math.floor(timeDiff / (60 * 60));
|
||||
const diffMinutes = Math.floor(timeDiff / 60);
|
||||
|
||||
// 顯示結果
|
||||
if (diffMonths > 1) {
|
||||
return moment(date).format('YYYY/MM/DD');
|
||||
}
|
||||
else if (diffDays > 1) {
|
||||
return moment(date).format('YYYY/MM/DD');
|
||||
}
|
||||
else if (diffHours > 1) {
|
||||
return moment(date).format('MM/DD hh:00');
|
||||
}
|
||||
else if (diffMinutes > 1) {
|
||||
return moment(date).format('MM/DD hh:mm');
|
||||
}
|
||||
else {
|
||||
return moment(date).format('hh:mm:ss');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select an appropriate time format based on the time difference.
|
||||
* 根據時間差距選擇適合的時間格式
|
||||
|
||||
Reference in New Issue
Block a user