From 79b45be5b67c96a00e35475cec8f8c2aea92d742 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Fri, 2 Jun 2023 11:17:20 +0000 Subject: [PATCH] debug(occurrences): find error in occurrencesAddBusinessDays --- src/Handler/Utils/Occurrences.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Handler/Utils/Occurrences.hs b/src/Handler/Utils/Occurrences.hs index f3412e29b..2d3aa97e2 100644 --- a/src/Handler/Utils/Occurrences.hs +++ b/src/Handler/Utils/Occurrences.hs @@ -51,8 +51,8 @@ occurrencesBounds Term{..} Occurrences{..} = (Set.lookupMin occDays, Set.lookupM getOccDays :: OccurrenceSchedule -> Set Day -> Set Day getOccDays ScheduleWeekly{scheduleDayOfWeek=wday} = Set.union $ daysOfWeekBetween (termLectureStart,termLectureEnd) wday -occurrencesAddBusinessDays :: Term -> (Day,Day) -> Occurrences -> Occurrences -occurrencesAddBusinessDays Term{..} (dayOld, dayNew) Occurrences{..} = Occurrences newSchedule newExceptions +occurrencesAddBusinessDays :: Term -> (Day,Day) -> Occurrences -> (Occurrences,_) +occurrencesAddBusinessDays Term{..} (dayOld, dayNew) Occurrences{..} = (Occurrences newSchedule newExceptions,(dayDiff, offDays,loff,dgb)) where newSchedule = Set.map switchDayOfWeek occurrencesScheduled dayDiff = diffDays dayNew dayOld @@ -64,16 +64,16 @@ occurrencesAddBusinessDays Term{..} (dayOld, dayNew) Occurrences{..} = Occurrenc switchDayOfWeek os | 0 == dayDiff `mod` 7 = os switchDayOfWeek os@ScheduleWeekly{scheduleDayOfWeek=wday} = os{scheduleDayOfWeek= toEnum (fromIntegral dayDiff + fromEnum wday)} - newExceptions = snd $ Set.foldr advanceExceptions (dayDiff,mempty) occurrencesExceptions + (loff,newExceptions,dgb) = Set.foldl (flip advanceExceptions) (dayDiff,mempty,mempty) occurrencesExceptions -- we assume that instance Ord OccurrenceException is ordered chronologically - advanceExceptions :: OccurrenceException -> (Integer, Set OccurrenceException) -> (Integer, Set OccurrenceException) - advanceExceptions ex (offset, acc) + advanceExceptions :: OccurrenceException -> (Integer, Set OccurrenceException,_) -> (Integer, Set OccurrenceException,_) + advanceExceptions ex (offset, acc, dbg) | ed `Set.notMember` offDays -- skip term-holidays and weekends, unless the original day was a holiday or weekend , nd `Set.member` offDays - = advanceExceptions ex (succ offset, acc) + = advanceExceptions ex (succ offset, acc, ("skip"<>show offset) :dbg) | otherwise - = (offset, Set.insert (setDayOfOccurrenceException nd ex) acc) + = (offset, Set.insert (setDayOfOccurrenceException nd ex) acc, show ex : dbg) where ed = dayOfOccurrenceException ex nd = addDays offset ed