[fit/mat-239] NotificationItem time formatDate 기능 수정#286
[fit/mat-239] NotificationItem time formatDate 기능 수정#286
Conversation
Show only date (M월 D일) instead of time when dateString lacks HH:MM pattern, even for today's notifications Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Updates notification/notice date labeling so that when the backend date string does not include a time (HH:MM), the UI shows only the date (M월 D일) even if it is today.
Changes:
- Added a
hasTimecheck (/\d{2}:\d{2}/) toformatDateto gate “오늘 HH:MM” formatting. - Applied the same formatting behavior to both the notice list and the notifications screen.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/native/src/features/student/menu/screens/NoticeScreen.tsx | Adjusts formatDate to avoid showing time for date-only strings. |
| apps/native/src/features/student/home/screens/notifications/NotificationsScreen.tsx | Applies the same formatDate change for both notices and notifications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const date = new Date(dateString); | ||
| const now = new Date(); | ||
| const hasTime = /\d{2}:\d{2}/.test(dateString); |
There was a problem hiding this comment.
dateString가 YYYY-MM-DD(time 미포함) 형태일 때 new Date(dateString)는 UTC 기준으로 파싱되어 로컬 타임존에 따라 날짜가 하루 밀릴 수 있습니다. (API 스키마에서 NoticeResp.startAt이 Format: date로 정의됨) hasTime === false인 경우에는 dateString + 'T00:00:00'처럼 로컬 기준으로 파싱되도록 정규화하거나, YYYY-MM-DD를 직접 분해해 new Date(y, m-1, d)로 생성해서 월/일 표시가 타임존에 영향받지 않게 해주세요.
| const date = new Date(dateString); | |
| const now = new Date(); | |
| const hasTime = /\d{2}:\d{2}/.test(dateString); | |
| const hasTime = /\d{2}:\d{2}/.test(dateString); | |
| const date = hasTime | |
| ? new Date(dateString) | |
| : (() => { | |
| const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateString); | |
| if (!match) { | |
| return new Date(dateString); | |
| } | |
| const [, year, month, day] = match; | |
| return new Date(Number(year), Number(month) - 1, Number(day)); | |
| })(); | |
| const now = new Date(); |
| const date = new Date(dateString); | ||
| const now = new Date(); | ||
| const hasTime = /\d{2}:\d{2}/.test(dateString); |
There was a problem hiding this comment.
dateString가 YYYY-MM-DD(time 미포함)일 경우 new Date(dateString)는 UTC로 해석되어 로컬 타임존에 따라 ${month}월 ${day}일 결과가 하루씩 어긋날 수 있습니다. 이 화면에서는 notice.startAt(스키마상 Format: date)에도 formatDate를 사용하므로, hasTime === false이면 dateString + 'T00:00:00'로 정규화하거나 new Date(y, m-1, d)로 생성해 날짜 표시가 타임존에 의존하지 않도록 처리해주세요.
| const date = new Date(dateString); | |
| const now = new Date(); | |
| const hasTime = /\d{2}:\d{2}/.test(dateString); | |
| const hasTime = /\d{2}:\d{2}/.test(dateString); | |
| const date = !hasTime && /^\d{4}-\d{2}-\d{2}$/.test(dateString) | |
| ? (() => { | |
| const [year, month, day] = dateString.split('-').map(Number); | |
| return new Date(year, month - 1, day); | |
| })() | |
| : new Date(dateString); | |
| const now = new Date(); |
Agent-Logs-Url: https://github.com/team-ppointer/Pointer/sessions/a6e8162a-a6e8-4f07-b0c6-1641b0e1d545 Co-authored-by: b0nsu <125778250+b0nsu@users.noreply.github.com>
| const hasTime = /\d{2}:\d{2}/.test(dateString); | ||
| const date = !hasTime && /^\d{4}-\d{2}-\d{2}$/.test(dateString) | ||
| ? (() => { | ||
| const [year, month, day] = dateString.split('-').map(Number); | ||
| return new Date(year, month - 1, day); | ||
| })() | ||
| : new Date(dateString); |
There was a problem hiding this comment.
이 스크린에서는 공지만 렌더링하고, 공지 데이터는 어차피 yyyy-MM-dd 형식으로만 들어오니까 hasTime과 알림용 시간 관련 분기들이 필요없음.
그리고 여기서 별도 로직을 유지하기보다는, 그냥 formatDate 지우고 분리해둔 @utils/dateFormatter.ts에서 formatNoticeDate를 그냥 import해서 사용하면 될듯.
There was a problem hiding this comment.
현재 hasTime에서 regex로 dateString 내에 시간 포함 여부를 확인하고, 이를 통해 공지 또는 알림 표시 형식을 간접적으로 결정하고 있음. 다만 해당 formatting 정책은 string 포맷이 아니라 도메인 타입에 종속되어 있고, 도메인 타입은 이미 호출부에서 알 수 있음.
- 공지: 항상
M월 d일(일단은 이렇게 보는게 맞을 것 같긴 한데, 기획이 모호하긴 함) - 알림: 오늘이면
오늘 HH:mm, 아니면M월 d일
각 도메인 타입 별로 적용해야 하는 formatting 정책이 명확한 만큼, 차라리 formatNoticeDate, formatNotificationDate 두 개로 분리하고, 호출부에서 도메인 타입에 맞는 적절한 함수를 사용하여 formatting을 진행하는 것이 명확해보임.
또한, 동일한 formatter가 NoticeScreen에서도 사용되고 있으므로, @utils/dateFormatter.ts 쪽으로 분리해두고, 각 화면에서 import해서 사용하는 게 더 좋을듯.
공지(formatNoticeDate)와 알림(formatNotificationDate)의 formatting 정책이 도메인 타입에 종속되므로, hasTime regex 분기 대신 호출부에서 적절한 함수를 선택하도록 변경. @utils/dateFormatter.ts로 공통화. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Show only date (M월 D일) instead of time when dateString lacks HH:MM pattern, even for today's notifications
Summary
알림/공지사항 목록에서 서버 응답에 시간 정보(HH:MM)가 없는 경우에도 오늘 00:00으로 표시되던 문제 수정. dateString에 시/분 패턴이
포함된 경우에만 시간을 표시하고, 없으면 날짜만 표시하도록 변경.
Linear
MAT-239: NotificationItem time formatDate 기능 수정 / ci
Changes
Testing
Risk / Impact
Screenshots / Video