chore(schedule-week): implement dayOffset
This commit is contained in:
parent
7c4dc0d6d6
commit
d19be72f58
@ -22,7 +22,7 @@ import Utils.Schedule.Week.TimeSlot
|
||||
|
||||
-- TODO: implement dayOffset
|
||||
weekSchedule :: UserId -> Maybe Integer -> Widget
|
||||
weekSchedule uid _dayOffset = do
|
||||
weekSchedule uid dayOffset = do
|
||||
now <- liftIO getCurrentTime
|
||||
tz <- liftIO getCurrentTimeZone
|
||||
ata <- getSessionActiveAuthTags
|
||||
@ -161,10 +161,11 @@ weekSchedule uid _dayOffset = do
|
||||
-- TODO: Internationalize default week start (and/or make configurable)
|
||||
-- TODO: auto-hide saturday and sunday (if there are no events scheduled)?
|
||||
week :: [Day]
|
||||
week = go $ utctDay now
|
||||
week = go $ fromMaybe 0 dayOffset `addDays` utctDay now
|
||||
where go day
|
||||
| Monday <- dayOfWeek day = [day .. toEnum (fromEnum day + 6)]
|
||||
| dayOfWeek day == firstDay = [day .. toEnum (fromEnum day + 6)]
|
||||
| otherwise = go $ pred day
|
||||
firstDay = toEnum $ fromEnum Monday + fromInteger (fromMaybe 0 dayOffset)
|
||||
|
||||
$(widgetFile "widgets/schedule/week")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user