Skip to content

feat(client): 레벨 페이지 시간 포맷 수정#177

Merged
jjangminii merged 1 commit intodevelopfrom
fix#176/level-page-arcon-time-count
Oct 2, 2025
Merged

feat(client): 레벨 페이지 시간 포맷 수정#177
jjangminii merged 1 commit intodevelopfrom
fix#176/level-page-arcon-time-count

Conversation

@jjangminii
Copy link
Collaborator

@jjangminii jjangminii commented Oct 2, 2025

📌 Related Issues

관련된 Issue를 태그해주세요. (e.g. - close #25)

📄 Tasks

  • 24시간 넘을경우 24시간 빼기

⭐ PR Point (To Reviewer)

📷 Screenshot

Summary by CodeRabbit

  • Bug Fixes
    • 카운트다운 타이머가 24시간을 초과해도 현재 일자 기준으로 올바르게 표시되도록 수정했습니다.
    • 현재 시각 처리 방식을 개선해 시간 계산의 드리프트와 오차를 줄였습니다.
    • 시간/분/초를 항상 두 자리로 표시해 가독성과 일관성을 높였습니다.
    • 종료 시점에 도달하면 타이머가 즉시 정지·초기화되는 동작을 유지하며 경계 상황 처리를 보강했습니다.

@jjangminii jjangminii linked an issue Oct 2, 2025 that may be closed by this pull request
@vercel
Copy link

vercel bot commented Oct 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
pinback-client-client Ready Ready Preview Comment Oct 2, 2025 4:45pm
pinback-client-landing Ready Ready Preview Comment Oct 2, 2025 4:45pm

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

카운트다운 훅의 시간 계산 방식을 리팩터링했습니다. Date.now() 사용, 하루(ms) 상수 추가, 하루 단위로 래핑하는 displayDiff 도입, 시·분·초 계산 로직 업데이트, 숫자 패딩 유틸리티(pad)로 포매팅 정리, 0 이하일 때 초기화 동작은 유지했습니다.

Changes

Cohort / File(s) Summary
Countdown hook formatting and day-wrap logic
apps/client/src/pages/level/hooks/useCountdown.ts
Date.now()로 현재 시간 획득, DAY 상수 도입, diff가 하루를 넘으면 당일 범위로 래핑해 표시(displayDiff), 포매팅 유틸을 pad로 교체, 시·분·초 계산 및 문자열 포맷 로직 정리, 종료 조건(diff <= 0) 처리 유지

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Level Page
  participant Hook as useCountdown
  participant Timer as setInterval
  participant Clock as Date.now()

  UI->>Hook: useCountdown(start, end)
  Hook->>Timer: setInterval(tick, 1000)
  loop every second
    Timer->>Clock: now = Date.now()
    Clock-->>Timer: ms
    Timer->>Hook: compute diff
    alt diff <= 0
      Hook->>Timer: clearInterval()
      Hook->>UI: set "00:00:00"
    else diff > 0
      Note over Hook: displayDiff = diff % DAY (하루 래핑)
      Hook->>UI: set hh:mm:ss (pad 적용)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

fix

Suggested reviewers

  • constantly-dev
  • jllee000

Poem

새벽 틱톡, 시계 톡톡—
하루를 감싸 도는 초의 춤.
패딩으로 단정히 매만진 시간,
00:00:00까지 고요히 달려가네.
(\/)

( •
•) ⏱️

/︶︶\ 오늘도 래빗은 시간을 헤엄친다.

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning PR 변경 내용이 레벨 페이지의 시간 포맷 수정에만 집중되어 있으며 링크된 이슈 #25의 디자인 시스템 프로그레스 바 구현 요구사항과 전혀 일치하지 않습니다. 링크된 이슈를 실제 구현하려는 작업에 맞게 수정하거나 PR에 프로그레스 바 구현 요구사항을 반영해 주세요.
Out of Scope Changes Check ⚠️ Warning PR이 레벨 페이지의 useCountdown 훅 개선만 다루고 있어 링크된 이슈 #25의 프로그레스 바 구현과 직접 관련 없는 변경 사항이 포함되어 있습니다. PR에서 링크된 이슈와 무관한 변경을 제거하거나 올바른 이슈를 연결해 주세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed 제목이 주요 변경 사항인 레벨 페이지의 시간 포맷 수정 내용을 간결하고 명확하게 요약하여 동료가 PR 히스토리를 빠르게 파악하기에 적절합니다.
Description Check ✅ Passed PR 설명이 템플릿에 맞춰 관련 이슈와 작업 섹션을 충실히 포함해 대부분 완성되었으나 PR 포인트와 스크린샷 섹션이 비어 있어 삭제하거나 내용을 추가하는 것이 좋습니다.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix#176/level-page-arcon-time-count

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jjangminii jjangminii changed the title feat: 시간 수정 feat(client): 레벨 페이지 시간 포맷 수정 Oct 2, 2025
@github-actions
Copy link

github-actions bot commented Oct 2, 2025

✅ Storybook chromatic 배포 확인:
🐿️ storybook

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e88b58f and c476f2c.

📒 Files selected for processing (1)
  • apps/client/src/pages/level/hooks/useCountdown.ts (2 hunks)
🔇 Additional comments (2)
apps/client/src/pages/level/hooks/useCountdown.ts (2)

8-11: 코드 개선이 적절합니다.

DAY 상수 추가와 Date.now() 사용은 코드 가독성과 성능 측면에서 좋은 개선입니다.


28-29: 포매팅 로직이 깔끔하게 개선되었습니다.

pad 함수는 명확하고 간결하며, padStart를 활용한 구현이 적절합니다.

const hours = Math.floor(diff / (1000 * 60 * 60));
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
const displayDiff = diff > DAY ? diff % DAY : diff;
Copy link

@coderabbitai coderabbitai bot Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

24시간 이상 카운트다운이 정확하게 표시되지 않습니다.

diff % DAY 로직은 24시간을 초과하는 카운트다운에서 문제를 일으킵니다:

  • 목표 시간이 2일 후라면 displayDiff = 0이 되어 "00:00:00"으로 표시됩니다.
  • 목표 시간이 25시간 후라면 displayDiff = 1시간이 되어 "01:00:00"으로 표시되어 실제 남은 시간을 알 수 없습니다.
  • 매 24시간마다 카운트다운이 "리셋"되는 것처럼 보여 사용자에게 혼란을 줄 수 있습니다.

24시간 이상의 카운트다운을 올바르게 표시하려면 다음 중 하나를 선택하세요:

방안 1: 일(day) 단위를 별도로 표시

-      const displayDiff = diff > DAY ? diff % DAY : diff;
+      const days = Math.floor(diff / DAY);
+      const remainingMs = diff % DAY;
 
-      const hours = Math.floor(displayDiff / (1000 * 60 * 60));
+      const hours = Math.floor(remainingMs / (1000 * 60 * 60));
       const minutes = Math.floor(
-        (displayDiff % (1000 * 60 * 60)) / (1000 * 60)
+        (remainingMs % (1000 * 60 * 60)) / (1000 * 60)
       );
-      const seconds = Math.floor((displayDiff % (1000 * 60)) / 1000);
+      const seconds = Math.floor((remainingMs % (1000 * 60)) / 1000);
 
       const pad = (n: number) => String(n).padStart(2, '0');
-      setTimeLeft(`${pad(hours)}:${pad(minutes)}:${pad(seconds)}`);
+      setTimeLeft(days > 0 ? `${days}일 ${pad(hours)}:${pad(minutes)}:${pad(seconds)}` : `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`);

방안 2: 시간을 24시간 이상 표시 (예: "25:30:15")

-      const displayDiff = diff > DAY ? diff % DAY : diff;
-
-      const hours = Math.floor(displayDiff / (1000 * 60 * 60));
+      const hours = Math.floor(diff / (1000 * 60 * 60));
       const minutes = Math.floor(
-        (displayDiff % (1000 * 60 * 60)) / (1000 * 60)
+        (diff % (1000 * 60 * 60)) / (1000 * 60)
       );
-      const seconds = Math.floor((displayDiff % (1000 * 60)) / 1000);
+      const seconds = Math.floor((diff % (1000 * 60)) / 1000);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const displayDiff = diff > DAY ? diff % DAY : diff;
// Instead of wrapping every 24h, compute days + remaining ms
const days = Math.floor(diff / DAY);
const remainingMs = diff % DAY;
const hours = Math.floor(remainingMs / (1000 * 60 * 60));
const minutes = Math.floor((remainingMs % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((remainingMs % (1000 * 60)) / 1000);
const pad = (n: number) => String(n).padStart(2, '0');
setTimeLeft(
days > 0
? `${days}${pad(hours)}:${pad(minutes)}:${pad(seconds)}`
: `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`
);
🤖 Prompt for AI Agents
In apps/client/src/pages/level/hooks/useCountdown.ts around line 20, the current
displayDiff = diff > DAY ? diff % DAY : diff causes countdowns >24 hours to
wrap/reset and display incorrect hours; fix by either (A) compute days =
Math.floor(diff / DAY) and keep remainder = diff % DAY then render days
separately while formatting remainder as HH:MM:SS, or (B) stop applying % DAY
and render total hours by computing hours = Math.floor(diff / HOUR) (which may
be >=24) and format as HH+:MM:SS; update the downstream formatting/rendering
code to accept and display the chosen days or multi-hour format accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 의도가 맞아요 24시간 이상의 시간이 24시간 이내 목표 시간까지 얼마나 남았는지 필요해서 그래요

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjangminii, 이해했습니다! 24시간 이상 남은 경우에도 현재 24시간 주기 내에서 목표 시간까지 남은 시간만 표시하는 것이 의도이시군요.

예를 들어:

  • 목표 시간이 25시간 후 → "01:00:00" 표시 (다음 24시간 주기에서 1시간 남음)
  • 목표 시간이 48시간 후 → "00:00:00" 표시 (정확히 2일 후)

diff % DAY 로직이 이 요구사항을 정확히 구현하고 있습니다. 제 이전 코멘트는 철회하겠습니다. 의도를 명확히 해주셔서 감사합니다! 👍

Copy link
Collaborator

@jllee000 jllee000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옹 깔쌈한 분기처리! 하루 지나가버린건 없애버려!

@jjangminii jjangminii merged commit c0a4aed into develop Oct 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] 레벨페이지 시간 초과 이슈

2 participants