From fcacb1811169d544e2b38e2709f1fff39b6f335a Mon Sep 17 00:00:00 2001 From: Theo Reichert Date: Wed, 15 Nov 2023 00:31:09 +0100 Subject: [PATCH] Fix calender() order in wrong calender day/cell --- src/main/java/catering/order/OrderController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/catering/order/OrderController.java b/src/main/java/catering/order/OrderController.java index ea54433..ec71149 100644 --- a/src/main/java/catering/order/OrderController.java +++ b/src/main/java/catering/order/OrderController.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; import java.time.LocalDate; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -138,10 +139,10 @@ public class OrderController { for (CustomOrder order : orders_in_next_month) { - int start_index_inclusive = Math.max(order.getStart().toLocalDate().compareTo(startDate),0); - int end_index_exclusive = Math.min(order.getFinish().toLocalDate().compareTo(startDate), 27) + 1; + int start_index_inclusive = Math.max((int) startDate.until(order.getStart().toLocalDate(), ChronoUnit.DAYS),0); + int end_index_exclusive = Math.min((int) startDate.until(order.getFinish().toLocalDate(), ChronoUnit.DAYS), 27) + 1; for (int i = start_index_inclusive; i < end_index_exclusive; i++) { - weeksOfMonth.get((int) i/7).get(Math.floorMod(i,7)).add(Integer.toString(order.getId())); + weeksOfMonth.get(Math.floorDiv(i,7)).get(Math.floorMod(i,7)).add(Integer.toString(order.getId())); } } // for (List> orders_in_next_week : orders_in_next_month) {