Skip to content

Commit

Permalink
Merge pull request #333 from first19326/dev
Browse files Browse the repository at this point in the history
🐞 fix: 修复时间胶囊周计算错误
  • Loading branch information
imsyy authored Aug 2, 2024
2 parents 7ecc902 + f616670 commit 23c59bf
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 23c59bf

Please sign in to comment.