diff options
author | Gordon GECOS <u@adam> | 2023-03-20 07:58:34 -0400 |
---|---|---|
committer | Gordon GECOS <u@adam> | 2023-03-20 07:58:34 -0400 |
commit | 6b7597d8c744284c8fa63b4d755b8a428cc7098f (patch) | |
tree | 3ae7660fc5eeedef0576658426c822136d15d585 /CosmicCalendar.hs | |
parent | 68a28047dc5fea08ee23418a6293ef4d42aa9496 (diff) |
factor out function "buildCalendar"
Diffstat (limited to 'CosmicCalendar.hs')
-rw-r--r-- | CosmicCalendar.hs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/CosmicCalendar.hs b/CosmicCalendar.hs index bab94da..db29c02 100644 --- a/CosmicCalendar.hs +++ b/CosmicCalendar.hs | |||
@@ -123,6 +123,9 @@ type Calendar = Map NominalDiffTime CalendarEntry | |||
123 | getNextCalendarEntry :: Calendar -> LocalTime -> Maybe CalendarEntry | 123 | getNextCalendarEntry :: Calendar -> LocalTime -> Maybe CalendarEntry |
124 | getNextCalendarEntry cal (localTimeToYearElapsed -> t) = snd <$> Map.lookupGT t cal | 124 | getNextCalendarEntry cal (localTimeToYearElapsed -> t) = snd <$> Map.lookupGT t cal |
125 | 125 | ||
126 | buildCalendar :: [CalendarEntry] -> Map NominalDiffTime CalendarEntry | ||
127 | buildCalendar ls = Map.fromList $ map (\x -> (calBeginTime x, x)) $ map unwrap ls | ||
128 | |||
126 | unwrap :: CalendarEntry -> CalendarEntry | 129 | unwrap :: CalendarEntry -> CalendarEntry |
127 | unwrap x@CalendarEntry{..} = x { calDescription = unwrapText calDescription } | 130 | unwrap x@CalendarEntry{..} = x { calDescription = unwrapText calDescription } |
128 | where | 131 | where |