Skip to content

Conversation

@Nangniya
Copy link
Member

@Nangniya Nangniya commented Apr 5, 2024

요약 (Summary)

useCalendar 리팩토링

변경 사항 (Changes)

  • 캘린더 데이터 조회할때 쓰는 날짜 형식 포맷 함수 분리
  • 불필요한 useMemo 제거
  • useEffect 의존 배열 최적화

리뷰 요구사항

확인 방법 (선택)

Comment on lines +43 to +57
//YYYY-MM 형태
export const formatRequestCalendarDate = (year: number, month: number) => {
return `${year}-${month + 1 < 10 ? '0' + (month + 1) : month + 1}`;
};

//YYYY-MM-DD 형태
export const formatCalendarListDay = (
year: number,
month: number,
day: number,
) => {
return `${year}-${month + 1 < 10 ? '0' + (month + 1) : month + 1}-${
day < 10 ? '0' + day : day
}`;
};

Choose a reason for hiding this comment

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

Suggested change
//YYYY-MM 형태
export const formatRequestCalendarDate = (year: number, month: number) => {
return `${year}-${month + 1 < 10 ? '0' + (month + 1) : month + 1}`;
};
//YYYY-MM-DD 형태
export const formatCalendarListDay = (
year: number,
month: number,
day: number,
) => {
return `${year}-${month + 1 < 10 ? '0' + (month + 1) : month + 1}-${
day < 10 ? '0' + day : day
}`;
};
export const formatCalendarDate = (year: number, month: number, day?: number) => {
const formattedMonth = month + 1 < 10 ? '0' + (month + 1) : month + 1;
return day ? `${year}-${formattedMonth}-${day < 10 ? '0' + day : day}` : `${year}-${formattedMonth}`;
};

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.

3 participants