mirror of
https://github.com/imsyy/home.git
synced 2024-11-15 19:22:18 +08:00
🐞 fix: 修复时间胶囊周计算错误
This commit is contained in:
parent
7ecc9026a5
commit
f616670e72
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user