/** * 한글 월 이름 배열 */ export const MONTHS_KR = [ '1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월' ]; /** * 현재 월 가져오기 */ export const getCurrentMonth = (): string => { const now = new Date(); const month = now.getMonth(); // 0-indexed return `${MONTHS_KR[month]}`; }; /** * 이전 월 가져오기 */ export const getPrevMonth = (currentMonth: string): string => { const currentMonthIdx = MONTHS_KR.findIndex(m => m === currentMonth); if (currentMonthIdx === 0) { // 1월인 경우 12월로 변경 return `${MONTHS_KR[11]}`; } else { const prevMonthIdx = currentMonthIdx - 1; return `${MONTHS_KR[prevMonthIdx]}`; } }; /** * 다음 월 가져오기 */ export const getNextMonth = (currentMonth: string): string => { const currentMonthIdx = MONTHS_KR.findIndex(m => m === currentMonth); if (currentMonthIdx === 11) { // 12월인 경우 1월로 변경 return `${MONTHS_KR[0]}`; } else { const nextMonthIdx = currentMonthIdx + 1; return `${MONTHS_KR[nextMonthIdx]}`; } };