summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2022-09-21 06:13:03 -0400
committerAndrew Cady <d@cryptonomic.net>2022-09-21 06:13:03 -0400
commit59056530f9fbaa15b7deb2f6d4ba42ec5d06c8e2 (patch)
treef597ba5fa20f2029cfbcfe7e459b18f8639c8dac
parent2b9a253814de4184d4144600210d5c87b0835acb (diff)
abbreviated display of "Next" calendar entry
-rwxr-xr-xcountdown.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/countdown.hs b/countdown.hs
index 70ecc99..5a5d718 100755
--- a/countdown.hs
+++ b/countdown.hs
@@ -217,7 +217,8 @@ countdownWidget showConversion isSimulated t =
217 hCenter (hBox [ 217 hCenter (hBox [
218 -- TODO: accumulate all entries on today's date into one vBox 218 -- TODO: accumulate all entries on today's date into one vBox
219 if currentEntryIsCurrent then 219 if currentEntryIsCurrent then
220 borderWithLabel (txt "Now on the Cosmic Calendar") currentEntry 220 (borderWithLabel (txt "Now on the Cosmic Calendar") currentEntry) <=>
221 (fromMaybe (str "") $ fmap (borderWithLabel (txt "Next on the Cosmic Calendar")) nextEntryShort)
221 else 222 else
222 borderWithLabel (txt "Next on the Cosmic Calendar") nextEntry, 223 borderWithLabel (txt "Next on the Cosmic Calendar") nextEntry,
223 -- vBox [ cosmicCalendarCurrent, txt "\n", cosmicCalendarNext ], 224 -- vBox [ cosmicCalendarCurrent, txt "\n", cosmicCalendarNext ],
@@ -240,10 +241,11 @@ countdownWidget showConversion isSimulated t =
240 (LocalTime entryDay _) <- (`addLocalTime` yearStart t) . calBeginTime <$> getCurrentCalendarEntry t 241 (LocalTime entryDay _) <- (`addLocalTime` yearStart t) . calBeginTime <$> getCurrentCalendarEntry t
241 let (LocalTime nowDay _) = t 242 let (LocalTime nowDay _) = t
242 return $ entryDay == nowDay 243 return $ entryDay == nowDay
243 currentEntry = fromMaybe (str "none") $ calendarWidget <$> getCurrentCalendarEntry t 244 currentEntry = fromMaybe (str "none") $ calendarWidget False <$> getCurrentCalendarEntry t
244 nextEntry = fromMaybe (str "none") $ calendarWidget <$> getNextCalendarEntry t 245 nextEntry = fromMaybe (str "none") $ calendarWidget False <$> getNextCalendarEntry t
246 nextEntryShort = fmap (str "\n" <=>) (calendarWidget True <$> getNextCalendarEntry t)
245 247
246 calendarWidget CalendarEntry{..} = box -- vBox [eventCountdown, str "\n", box] 248 calendarWidget short CalendarEntry{..} = box -- vBox [eventCountdown, str "\n", box]
247 where 249 where
248 timeUntilActive = (calBeginTime `addLocalTime` yearStart t) `diffLocalTime` t 250 timeUntilActive = (calBeginTime `addLocalTime` yearStart t) `diffLocalTime` t
249 eventCountdown = if timeUntilActive >= 0 then 251 eventCountdown = if timeUntilActive >= 0 then
@@ -254,7 +256,7 @@ countdownWidget showConversion isSimulated t =
254 padLeft Max $ str $ showCosmicTime (-timeUntilActive) ++ " ago"] 256 padLeft Max $ str $ showCosmicTime (-timeUntilActive) ++ " ago"]
255 years = fromRational $ toCosmicTime calBeginTime 257 years = fromRational $ toCosmicTime calBeginTime
256 box = vBox [ 258 box = vBox [
257 if currentEntryIsCurrent 259 if currentEntryIsCurrent && not short
258 then str "\n" 260 then str "\n"
259 else eventCountdown <=> str "\n", 261 else eventCountdown <=> str "\n",
260 hCenter $ txt calTitle, 262 hCenter $ txt calTitle,
@@ -269,8 +271,12 @@ countdownWidget showConversion isSimulated t =
269 ], 271 ],
270 -- str $ printf "%s years ago" (commas $ ageOfUniverseInYears - floor years), 272 -- str $ printf "%s years ago" (commas $ ageOfUniverseInYears - floor years),
271 str $ printf "%s years ago" $ showLarge $ realToFrac (ageOfUniverseInYears - floor years), 273 str $ printf "%s years ago" $ showLarge $ realToFrac (ageOfUniverseInYears - floor years),
272 str "\n", 274 if not short
273 txtWrap calDescription 275 then
276 str "\n" <=>
277 txtWrap calDescription
278 else
279 str ""
274 ] 280 ]
275 281
276 countdownBox = 282 countdownBox =