Skip to content

Commit

Permalink
fix : prevent negative time values in countdown timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Minsoek96 committed Dec 13, 2024
1 parent f09a55b commit d2b950e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/assets/ts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ const parseGoalTime = (goalTime: number) => {
// goalTime이 밀리초 단위라면 초 단위로 변환

const totalTime = goalTime - Math.floor(new Date().getTime() / 1000); // 밀리초 -> 초로 변환
if (totalTime < 0) {
return {
days: 0,
hours: 0,
minutes: 0
};
}

// 일, 시, 분 계산
const days = Math.floor(totalTime / 86400); // 1일 = 86400초
Expand Down

0 comments on commit d2b950e

Please sign in to comment.