重构代码, 移除warning

This commit is contained in:
zhl 2021-05-18 15:18:33 +08:00
parent bad0f18620
commit d5c125b87e

View File

@ -35,7 +35,7 @@ export const parseTime = (
s: date.getSeconds(),
a: date.getDay()
}
const timeStr = format.replace(/{([ymdhisa])+}/g, (result, key) => {
return format.replace(/{([ymdhisa])+}/g, (result, key) => {
const value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
@ -43,18 +43,17 @@ export const parseTime = (
}
return value.toString().padStart(2, '0')
})
return timeStr
}
/**
* 小时:分钟:
* @param {number} sec
* @param showSeconds
*/
export const sec2TimeStr= (sec: number, showSeconds: boolean = true) => {
showSeconds = typeof showSeconds !== 'undefined' ? showSeconds : true;
let t = sec % 60
let i = (sec % 3600 - t) / 60
let n = Math.floor(sec / 3600)
export const sec2TimeStr = (sec: number, showSeconds = true) => {
showSeconds = typeof showSeconds !== 'undefined' ? showSeconds : true
const t = sec % 60
const i = (sec % 3600 - t) / 60
const n = Math.floor(sec / 3600)
if (showSeconds) {
return (n > 9 ? '' + n : '0' + n) + ':' + (i > 9 ? i : '0' + i) + ':' + (t > 9 ? t : '0' + t)
} else {