refactor(schedule-week): minor TimeSlot refactor
This commit is contained in:
parent
113f21fc29
commit
7856aba24d
@ -113,11 +113,11 @@ weekSchedule uid dayOffset = do
|
||||
|
||||
seOccurrenceIsInSlot :: Day -> TimeSlot -> ScheduleEntryOccurrence -> Bool
|
||||
seOccurrenceIsInSlot day slot = \case
|
||||
Right occurrence -> occStart `isInTimeSlot` (day, slot) where
|
||||
occStart = case occurrence of
|
||||
Right ScheduleWeekly{..} -> (scheduleDayOfWeek `dayOfWeekToDayWith` now, scheduleStart)
|
||||
Left ExceptOccur{..} -> (exceptDay, exceptStart)
|
||||
Left ExceptNoOccur{exceptTime=LocalTime{..}} -> (localDay, localTimeOfDay)
|
||||
Right occurrence -> occDay == day && occTime `isInTimeSlot` slot where
|
||||
(occDay,occTime) = case occurrence of
|
||||
Right ScheduleWeekly{..} -> (scheduleDayOfWeek `dayOfWeekToDayWith` now, scheduleStart)
|
||||
Left ExceptOccur{..} -> (exceptDay, exceptStart)
|
||||
Left ExceptNoOccur{exceptTime=LocalTime{..}} -> (localDay, localTimeOfDay)
|
||||
Left ScheduleEntryExamOccurrence{..} -> let slotUTCTime = timeSlotToUTCTime tz day slot
|
||||
nextSlotUTCTime = timeSlotToUTCTime tz day (slot+slotStep)
|
||||
in slotUTCTime <= seeoStart
|
||||
|
||||
@ -21,9 +21,10 @@ slotStep = 2
|
||||
slotsToDisplay :: [TimeSlot]
|
||||
slotsToDisplay = [firstSlot,firstSlot+slotStep..lastSlot]
|
||||
|
||||
isInTimeSlot :: (Day, TimeOfDay) -> (Day, TimeSlot) -> Bool
|
||||
isInTimeSlot (day,time) (slotDay,slotHour) = day == slotDay && TimeOfDay slotHour 0 0 <= time && time < TimeOfDay (slotHour+slotStep) 0 0
|
||||
|
||||
-- | Check whether a given time of day lies within a given time slot
|
||||
isInTimeSlot :: TimeOfDay -> TimeSlot -> Bool
|
||||
isInTimeSlot time slot = TimeOfDay slot 0 0 <= time && time < TimeOfDay (slot+slotStep) 0 0
|
||||
|
||||
-- | Convert a TimeSlot to UTCTime for a given TimeZone
|
||||
timeSlotToUTCTime :: TimeZone -> Day -> TimeSlot -> UTCTime
|
||||
@ -32,7 +33,6 @@ timeSlotToUTCTime tz day slot = UTCTime{..} where
|
||||
utctDayTime = timeOfDayToTime slotTimeOfDay
|
||||
(slotDayOffset, slotTimeOfDay) = localToUTCTimeOfDay tz $ TimeOfDay slot 0 0
|
||||
|
||||
|
||||
-- TODO: refactor in progress
|
||||
-- | Format a given TimeSlot t as time range from t until the next TimeSlot
|
||||
formatTimeSlotW :: TimeSlot -> Widget
|
||||
|
||||
Reference in New Issue
Block a user