Skip to content

Commit

Permalink
fix (#4) : 알고리즘 오류 해결, 두 날짜 사이 dday 구하기
Browse files Browse the repository at this point in the history
  • Loading branch information
daehwan2yo committed Apr 11, 2022
1 parent 94095dc commit 5446337
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.codingwasabi.howtodo.web.policy.util.ExamDateSorting.*;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -143,13 +144,17 @@ private Map<LocalDate, Integer> initDailyHours(List<Exam> exams, LocalDate today
LocalDate endDate = exams.get(exams.size() - 1)
.getDueDateTime()
.toLocalDate();
int days = getDays(today, endDate);

for (int day = 1; day < today.until(endDate)
.getDays(); day++) {
for (int day = 1; day < days; day++) {
nextDay = nextDay.plusDays(1);
dailyHours.put(nextDay, 0);
}

return dailyHours;
}

private int getDays(LocalDate start, LocalDate end) {
return (int)ChronoUnit.DAYS.between(start, end);
}
}

0 comments on commit 5446337

Please sign in to comment.