30 lines
1.1 KiB
Haskell
30 lines
1.1 KiB
Haskell
module Handler.Utils.Occurrences
|
|
( occurrencesWidget
|
|
) where
|
|
|
|
import Import
|
|
|
|
import qualified Data.Set as Set
|
|
|
|
import Utils.Occurrences
|
|
|
|
import Handler.Utils.DateTime
|
|
|
|
|
|
occurrencesWidget :: Occurrences -> Widget
|
|
occurrencesWidget (normalizeOccurrences -> Occurrences{..}) = do
|
|
let occurrencesScheduled' = flip map (Set.toList occurrencesScheduled) $ \case
|
|
ScheduleWeekly{..} -> do
|
|
scheduleStart' <- formatTime SelFormatTime scheduleStart
|
|
scheduleEnd' <- formatTime SelFormatTime scheduleEnd
|
|
$(widgetFile "widgets/occurrence/cell/weekly")
|
|
occurrencesExceptions' = flip map (Set.toList occurrencesExceptions) $ \case
|
|
ExceptOccur{..} -> do
|
|
exceptStart' <- formatTime SelFormatDateTime (LocalTime exceptDay exceptStart)
|
|
exceptEnd' <- formatTime SelFormatTime exceptEnd
|
|
$(widgetFile "widgets/occurrence/cell/except-occur")
|
|
ExceptNoOccur{..} -> do
|
|
exceptTime' <- formatTime SelFormatDateTime exceptTime
|
|
$(widgetFile "widgets/occurrence/cell/except-no-occur")
|
|
$(widgetFile "widgets/occurrence/cell")
|