Refactor useTransactions hook
Splits the useTransactions hook into smaller, more manageable files for improved code organization and maintainability. The original functionality of the hook remains unchanged.
This commit is contained in:
23
src/hooks/transactions/dateUtils.ts
Normal file
23
src/hooks/transactions/dateUtils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
// 월 이름 상수와 날짜 관련 유틸리티 함수
|
||||
|
||||
// 월 이름 상수
|
||||
export const MONTHS_KR = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'];
|
||||
|
||||
// 현재 월 가져오기
|
||||
export const getCurrentMonth = () => {
|
||||
const today = new Date();
|
||||
return MONTHS_KR[today.getMonth()];
|
||||
};
|
||||
|
||||
// 이전 월 가져오기
|
||||
export const getPrevMonth = (currentMonth: string) => {
|
||||
const index = MONTHS_KR.indexOf(currentMonth);
|
||||
return index > 0 ? MONTHS_KR[index - 1] : MONTHS_KR[11];
|
||||
};
|
||||
|
||||
// 다음 월 가져오기
|
||||
export const getNextMonth = (currentMonth: string) => {
|
||||
const index = MONTHS_KR.indexOf(currentMonth);
|
||||
return index < 11 ? MONTHS_KR[index + 1] : MONTHS_KR[0];
|
||||
};
|
||||
Reference in New Issue
Block a user