diff --git a/src/utils/index.ts b/src/utils/index.ts index 840c5df..06756d9 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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 {