Skip to content

Commit d514f3f

Browse files
committed
refactor: 7일 이상 시 상대 시간 표현으로 변경
1 parent 20e9b54 commit d514f3f

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

frontend/src/utils/timeUtils.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ export function getRelativeTime(isoString: string): string {
3131
return `${diffHours}시간 전`;
3232
}
3333

34-
// 7일 미만
35-
if (diffDays < 7) {
34+
// 30일 미만
35+
if (diffDays < 30) {
3636
return `${diffDays}일 전`;
3737
}
3838

39-
// 7일 이상 - 날짜 표시
40-
return date.toLocaleDateString('ko-KR', {
41-
year: 'numeric',
42-
month: 'long',
43-
day: 'numeric',
44-
});
39+
// 365일 미만 - 개월 단위
40+
if (diffDays < 365) {
41+
const diffMonths = Math.floor(diffDays / 30);
42+
return `${diffMonths}개월 전`;
43+
}
44+
45+
// 365일 이상 - 년 단위
46+
const diffYears = Math.floor(diffDays / 365);
47+
return `${diffYears}년 전`;
4548
}

0 commit comments

Comments
 (0)