Merge pull request #333 from first19326/dev
Some checks failed
Build Dev / Build Website (push) Has been cancelled

🐞 fix: 修复时间胶囊周计算错误
This commit is contained in:
底层用户 2024-08-02 14:49:00 +08:00 committed by GitHub
commit 23c59bfa44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;