Skip to content

Commit

Permalink
Merge pull request #86 from Minsoek96/dev/expirationDate
Browse files Browse the repository at this point in the history
fix : prevent negative time values in countdown timer
  • Loading branch information
bunzzeok authored Dec 17, 2024
2 parents f09a55b + d2b950e commit e8d8deb
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 e8d8deb

Please sign in to comment.