summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2022-09-23 12:31:39 -0400
committerAndrew Cady <d@cryptonomic.net>2022-09-23 20:39:10 -0400
commitce8da88eb752a8c5cd4e8748c62c73446224477d (patch)
treef510df563115363470b026931dbe5bb6ec22e0f7
parentadc08a0a62056b8bba9c6f0e289e9c8274633770 (diff)
slight refactor
-rwxr-xr-xcountdown.hs70
1 files changed, 34 insertions, 36 deletions
diff --git a/countdown.hs b/countdown.hs
index 0d072e1..f9da70e 100755
--- a/countdown.hs
+++ b/countdown.hs
@@ -285,44 +285,42 @@ countdownWidget showConversion isSimulated t =
285 str "" 285 str ""
286 ] 286 ]
287 287
288 strWhen b s = str $ if b then s else ""
288 countdownBox = 289 countdownBox =
289 (borderWithLabel (str $ printf "Countdown %d" currentYear) $ 290 (borderWithLabel (str $ printf "Countdown %d" currentYear) $
290 (str $ printf "Day %d of %d; %d remaining\nSecond %s of %s" 291 vBox $
291 dayNum 292 (str $ printf "Day %d of %d\nSecond %s of %s"
292 numDays 293 dayNum
293 daysLeft 294 numDays
294 (commas $ (1 + toSeconds yearElapsed :: Int)) 295 (commas $ (1 + toSeconds yearElapsed :: Int))
295 (commas $ toSeconds yearLength)) 296 (commas $ toSeconds yearLength)) : remains
296 <=> 297 )
297 -- (str $ printf "%d day%s remain%s" 298 remains =
298 -- daysLeft 299 [
299 -- (pluralize daysLeft) 300 strWhen (hoursLeft >= 24) $
300 -- (pluralizeVerb daysLeft) 301 printf "%d day%s remain%s"
301 -- ) 302 daysLeft
302 -- <=> 303 (pluralize daysLeft)
303 (str $ if hoursLeft < 24 && hoursLeft > 1 304 (pluralizeVerb daysLeft),
304 then 305
305 printf "%s hour%s remain%s" 306 strWhen (hoursLeft < 24 && hoursLeft > 1) $
306 (commasF 2 hoursLeft) 307 printf "%s hour%s remain%s"
307 (pluralize $ (floor hoursLeft :: Integer)) 308 (commasF 2 hoursLeft)
308 (pluralizeVerb $ (floor hoursLeft :: Integer)) 309 (pluralize $ (floor hoursLeft :: Integer))
309 else "") 310 (pluralizeVerb $ (floor hoursLeft :: Integer)),
310 <=> 311
311 (str $ if hoursLeft <= 1 && minutesLeft > 1 312 strWhen (hoursLeft <= 1 && minutesLeft > 1) $
312 then 313 printf "%s minute%s remain%s"
313 printf "%s minute%s remain%s" 314 (commasF 2 minutesLeft)
314 (commasF 2 minutesLeft) 315 (pluralize $ (floor minutesLeft :: Integer))
315 (pluralize $ (floor minutesLeft :: Integer)) 316 (pluralizeVerb $ (floor minutesLeft :: Integer)),
316 (pluralizeVerb $ (floor minutesLeft :: Integer)) 317
317 else "") 318 strWhen (minutesLeft <= 1) $
318 <=> 319 printf "%s second%s remain%s"
319 (str $ if minutesLeft <= 1 320 (commasF' 1 secondsLeft)
320 then 321 (pluralize secondsLeft)
321 printf "%s second%s remain%s" 322 (pluralizeVerb secondsLeft)
322 (commasF' 1 secondsLeft) 323 ]
323 (pluralize secondsLeft)
324 (pluralizeVerb secondsLeft)
325 else ""))
326 324
327 cosmicTimeBox = 325 cosmicTimeBox =
328 (borderWithLabel (str "Cosmic Time") $ 326 (borderWithLabel (str "Cosmic Time") $