Skip to content

Commit

Permalink
#205 fix: 연도 걸치는 타임 블록 배치 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
namdaeun committed Aug 3, 2024
1 parent 224bb0f commit b649cbc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/page/archiving/index/util/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,24 @@ export const createTimeBlock = ({ startDate, endDate, currentYear, selectedMonth

if (blockStartDate.getFullYear() === currentYear && blockEndDate.getFullYear() === currentYear) {
if (startMonth < selectedMonth && selectedMonth < endMonth) {
// 타임블록이 3달 이상의 기간을 가질 때
blockStartDate = startMonth === selectedMonth ? blockStartDate : firstDay;
blockEndDate = endMonth === selectedMonth ? blockEndDate : lastDay;
} else if (startMonth !== selectedMonth && endMonth === selectedMonth) {
blockStartDate = firstDay;
} else if (startMonth === selectedMonth && endMonth !== selectedMonth) {
blockEndDate = lastDay;
} else if (startMonth !== selectedMonth) {
}
} else {
if (startMonth <= selectedMonth || selectedMonth <= endMonth) {
blockStartDate =
startMonth === selectedMonth && blockStartDate.getFullYear() === currentYear ? blockStartDate : firstDay;
blockEndDate = endMonth === selectedMonth && blockEndDate.getFullYear() === currentYear ? blockEndDate : lastDay;
} else {
blockStartDate = firstDay;
} else if (endMonth !== selectedMonth) {
blockEndDate = lastDay;
}
}

return { startDate: blockStartDate, endDate: blockEndDate };
};

Expand Down

0 comments on commit b649cbc

Please sign in to comment.