From d5c125b87e6fecc51f89cd6f3c11044bb91b9c65 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 18 May 2021 15:18:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 {