Skip to content

Commit

Permalink
♻️ eslint 주석 삭제 후 수정 (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaeng committed Jan 22, 2025
1 parent 09b35c3 commit ba702e9
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/utils/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,17 @@ export const formatChatItemTime = (date: string) => {
const hour = Number(hourStr);

const period = hour < 12 ? '오전' : '오후';
// eslint-disable-next-line no-nested-ternary
const formattedHour = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;

let formattedHour;

if (hour === 0) {
formattedHour = 12;
} else if (hour > 12) {
formattedHour = hour - 12;
} else {
formattedHour = hour;
}

return `${period} ${formattedHour}:${minute}`;
};

Expand All @@ -90,21 +99,14 @@ export const formatChatListItemTime = (date: string) => {

const today = new Date();
const targetDate = new Date(datePart);
if (
targetDate.getFullYear() === today.getFullYear() &&
targetDate.getMonth() === today.getMonth() &&
targetDate.getDate() === today.getDate()
) {

if (targetDate.toDateString() === today.toDateString()) {
return formatChatItemTime(timePart);
}

const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
if (
targetDate.getFullYear() === yesterday.getFullYear() &&
targetDate.getMonth() === yesterday.getMonth() &&
targetDate.getDate() === yesterday.getDate()
) {
if (targetDate.toDateString() === yesterday.toDateString()) {
return '어제';
}

Expand Down

0 comments on commit ba702e9

Please sign in to comment.