Skip to content

Commit

Permalink
Merge pull request #84 from innovationacademy-kr/fe/dev/fix_calcOptions/
Browse files Browse the repository at this point in the history
#83

[FE] FIX: 월선택 제대로 안나오는 부분 수정 #83
  • Loading branch information
42inshin authored Dec 31, 2023
2 parents 6463b37 + a749d48 commit 1ef723b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/stores/monthlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ export const useMonthLogStore = defineStore("MonthLog", () => {
// 달력에 보여줄 날짜 계산하기
const calcOptions = () => {
const options = [];
for (let year = FIRST_DAY.year; year <= showToday().getFullYear(); year++) {
if (year == FIRST_DAY.year) {
for (let month = FIRST_DAY.month - 1; month < 12; month++) {
options.push(`${year}. ${month + 1}`);
}
continue;
} else {
for (let month = 0; month <= showToday().getMonth(); month++) {
options.push(`${year}. ${month + 1}`);
}
const currentYear = showToday().getFullYear();
const currentMonth = showToday().getMonth();

for (let year = FIRST_DAY.year; year <= currentYear; year++) {
const startMonth = year === FIRST_DAY.year ? FIRST_DAY.month - 1 : 0;
const endMonth = year === currentYear ? currentMonth : 11;

for (let month = startMonth; month <= endMonth; month++) {
options.push(`${year}. ${month + 1}`);
}
}

return options;
};

Expand Down

0 comments on commit 1ef723b

Please sign in to comment.