diff options
author | Andrew Cady <d@cryptonomic.net> | 2022-09-16 23:34:18 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2022-09-16 23:34:18 -0400 |
commit | c4b5ffaffcfc72eac46b4c345af5be55fb551082 (patch) | |
tree | bbc38d5689dcf64eb562f235e353224abd185249 | |
parent | 595ec01214bc1552bdc47b3212caeda274fc9d03 (diff) |
calculate whether displayed calendar entry is current (present day)
-rwxr-xr-x | countdown.hs | 6 |
1 files changed, 5 insertions, 1 deletions
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 = | |||
217 | where | 217 | where |
218 | cosmicCalendarCurrent = borderWithLabel (str $ (if current then "Now" else "Previously") ++ " on the Cosmic Calendar") currentEntry | 218 | cosmicCalendarCurrent = borderWithLabel (str $ (if current then "Now" else "Previously") ++ " on the Cosmic Calendar") currentEntry |
219 | where | 219 | where |
220 | current = True | 220 | current = currentEntryIsCurrent |
221 | cosmicCalendarNext = borderWithLabel (txt "Next on the Cosmic Calendar") nextEntry | 221 | cosmicCalendarNext = borderWithLabel (txt "Next on the Cosmic Calendar") nextEntry |
222 | 222 | ||
223 | -- TODO: We want to display "today" or "now" on the cosmic calendar; | 223 | -- TODO: We want to display "today" or "now" on the cosmic calendar; |
@@ -228,6 +228,10 @@ countdownWidget isSimulated t = | |||
228 | -- We also _may_ want to say the same thing for the current happening, depending on if it's an instant or a stage | 228 | -- We also _may_ want to say the same thing for the current happening, depending on if it's an instant or a stage |
229 | -- If it's a stage, we want to say how long it lasts; how long since it started, and how long until it ends | 229 | -- If it's a stage, we want to say how long it lasts; how long since it started, and how long until it ends |
230 | 230 | ||
231 | currentEntryIsCurrent = fromMaybe True $ do | ||
232 | (LocalTime entryDay _) <- (`addLocalTime` yearStart t) . calBeginTime <$> getCurrentCalendarEntry t | ||
233 | let (LocalTime nowDay _) = t | ||
234 | return $ entryDay == nowDay | ||
231 | currentEntry = fromMaybe (str "none") $ calendarWidget <$> getCurrentCalendarEntry t | 235 | currentEntry = fromMaybe (str "none") $ calendarWidget <$> getCurrentCalendarEntry t |
232 | nextEntry = fromMaybe (str "none") $ calendarWidget <$> getNextCalendarEntry t | 236 | nextEntry = fromMaybe (str "none") $ calendarWidget <$> getNextCalendarEntry t |
233 | 237 | ||