From f616670e721ff4bf0a9d0493f5c215fdb040b438 Mon Sep 17 00:00:00 2001 From: first19326 <870390039@qq.com> Date: Tue, 30 Jul 2024 02:05:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=83=B6=E5=9B=8A=E5=91=A8=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/getTime.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/getTime.js b/src/utils/getTime.js index 9c29b13..cf2d255 100644 --- a/src/utils/getTime.js +++ b/src/utils/getTime.js @@ -45,12 +45,9 @@ export const getTimeCapsule = () => { // 计算总的天数或小时数 const total = end.diff(start, unit === "day" ? "hour" : "day") + 1; // 计算已经过去的天数或小时数 - let passed; - if (unit === "week" && now.day() === 0) { - // 如果是星期日 - passed = total - 1; - } else { - passed = now.diff(start, unit === "day" ? "hour" : "day"); + let passed = now.diff(start, unit === "day" ? "hour" : "day"); + if (unit === "week") { + passed = (passed + 6) % 7; } const remaining = total - passed; const percentage = (passed / total) * 100;