diff --git a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java index 2e3eb3d..74d67dd 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java @@ -176,13 +176,10 @@ public class GardenSchedule { dayTaskList.add(new ArrayList<>()); final int finalI = i; weekTasks.forEach(task -> { - if (task.getNextExecution() == null) { - task.isDone(); - } else { + if(task.getNextExecution() != null) { LocalDate checkDate = task.getNextExecution(); - do { - if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { + if (date.equals(task.getNextExecution()) || (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN)))) { dayTaskList.get(finalI).add(task); } checkDate = checkDate.plusDays(task.getInterval().orElse(0)); diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java b/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java index d235918..c6eb57a 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java @@ -107,7 +107,7 @@ public class Task { * @return Whether the Task is within the given range */ public boolean isInTimePeriod(LocalDate searchStartDate, LocalDate searchEndDate) { - return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate) || (nextExecution != null && nextExecution.isBefore(searchEndDate) && nextExecution.isAfter(searchStartDate)); + return (endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate)) || ((nextExecution != null && nextExecution.isBefore(searchEndDate.plusDays(1)) && nextExecution.isAfter(searchStartDate.minusDays(1)))); } /**