From c4b5ffaffcfc72eac46b4c345af5be55fb551082 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 16 Sep 2022 23:34:18 -0400 Subject: calculate whether displayed calendar entry is current (present day) --- countdown.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/countdown.hs b/countdown.hs index 42675f6..c415e39 100755 --- a/countdown.hs +++ b/countdown.hs @@ -217,7 +217,7 @@ countdownWidget isSimulated t = where cosmicCalendarCurrent = borderWithLabel (str $ (if current then "Now" else "Previously") ++ " on the Cosmic Calendar") currentEntry where - current = True + current = currentEntryIsCurrent cosmicCalendarNext = borderWithLabel (txt "Next on the Cosmic Calendar") nextEntry -- TODO: We want to display "today" or "now" on the cosmic calendar; @@ -228,6 +228,10 @@ countdownWidget isSimulated t = -- We also _may_ want to say the same thing for the current happening, depending on if it's an instant or a stage -- If it's a stage, we want to say how long it lasts; how long since it started, and how long until it ends + currentEntryIsCurrent = fromMaybe True $ do + (LocalTime entryDay _) <- (`addLocalTime` yearStart t) . calBeginTime <$> getCurrentCalendarEntry t + let (LocalTime nowDay _) = t + return $ entryDay == nowDay currentEntry = fromMaybe (str "none") $ calendarWidget <$> getCurrentCalendarEntry t nextEntry = fromMaybe (str "none") $ calendarWidget <$> getNextCalendarEntry t -- cgit v1.2.3