cyroscape map done

This commit is contained in:
chiayin
2023-03-01 09:25:24 +08:00
parent 7e4d7b1e1f
commit cf2ec242aa
2 changed files with 72 additions and 28 deletions

26
src/module/timeLabel.js Normal file
View File

@@ -0,0 +1,26 @@
/**
* 將秒數轉換成帶有時間單位的格式
* @param {number} Second
* @returns {string} 轉換完的格式(ex: 1 day, 6.8 hrs)
*/
export default function TimeLabel(Second) {
var day = 24 * 60 * 60
var hour = 60 * 60
var minutes = 60
var dd = Math.floor(Second / day)
var hh = Math.floor((Second % day) / hour)
var mm = Math.floor((Second % hour) / minutes)
if(dd > 0){
return dd + " days"
}
else if(hh > 0){
return hh + " hrs"
}
else if(mm > 0){
return mm + " mins"
}
if(Second == 0){
return Second + " sec"
}
return Second + " secs"
}