mirror of
https://github.com/imsyy/home.git
synced 2024-11-15 19:22:18 +08:00
Merge pull request #333 from first19326/dev
Some checks failed
Build Dev / Build Website (push) Has been cancelled
Some checks failed
Build Dev / Build Website (push) Has been cancelled
🐞 fix: 修复时间胶囊周计算错误
This commit is contained in:
commit
23c59bfa44
|
@ -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