Fix month display in transactions

Corrected the month display in the transactions list to remove the duplicate month number.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-17 23:33:46 +00:00
parent 042965461e
commit d48b866b3a
2 changed files with 11 additions and 14 deletions

View File

@@ -1,3 +1,4 @@
/**
* 한글 월 이름 배열
*/
@@ -12,23 +13,21 @@ export const MONTHS_KR = [
export const getCurrentMonth = (): string => {
const now = new Date();
const month = now.getMonth(); // 0-indexed
const monthNumber = now.getMonth() + 1; // 1-indexed
return `${MONTHS_KR[month]} ${monthNumber}`;
return `${MONTHS_KR[month]}`;
};
/**
* 이전 월 가져오기
*/
export const getPrevMonth = (currentMonth: string): string => {
const parts = currentMonth.split(' ');
const currentMonthIdx = MONTHS_KR.findIndex(m => m === parts[0]);
const currentMonthIdx = MONTHS_KR.findIndex(m => m === currentMonth);
if (currentMonthIdx === 0) {
// 1월인 경우 12월로 변경
return `${MONTHS_KR[11]} 12`;
return `${MONTHS_KR[11]}`;
} else {
const prevMonthIdx = currentMonthIdx - 1;
return `${MONTHS_KR[prevMonthIdx]} ${prevMonthIdx + 1}`;
return `${MONTHS_KR[prevMonthIdx]}`;
}
};
@@ -36,14 +35,13 @@ export const getPrevMonth = (currentMonth: string): string => {
* 다음 월 가져오기
*/
export const getNextMonth = (currentMonth: string): string => {
const parts = currentMonth.split(' ');
const currentMonthIdx = MONTHS_KR.findIndex(m => m === parts[0]);
const currentMonthIdx = MONTHS_KR.findIndex(m => m === currentMonth);
if (currentMonthIdx === 11) {
// 12월인 경우 1월로 변경
return `${MONTHS_KR[0]} 1`;
return `${MONTHS_KR[0]}`;
} else {
const nextMonthIdx = currentMonthIdx + 1;
return `${MONTHS_KR[nextMonthIdx]} ${nextMonthIdx + 1}`;
return `${MONTHS_KR[nextMonthIdx]}`;
}
};