Skip to content

Commit

Permalink
🐞 fix: 修复时间胶囊周计算错误
Browse files Browse the repository at this point in the history
  • Loading branch information
first19326 committed Jul 29, 2024
1 parent 7ecc902 commit f616670
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/utils/getTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f616670

Please sign in to comment.