Skip to content

Commit 1304c13

Browse files
Add tenth-seconds to clock.
1 parent f5e6266 commit 1304c13

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

UI.hs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,25 @@ exitModal swd = (wd, ["", padl <> "Exit (y)?", ""]) where
250250

251251
------------------------------------------------------------------------
252252

253+
showClock :: Fixed E2 -> ByteString
254+
showClock t =
255+
let m, si, sd :: Int
256+
(m, s) = t `divMod'` 60
257+
si = floor s
258+
sd = floor (s*10) `mod` 10
259+
in P.pack $ printf "%d:%02d.%d" m si sd
260+
253261
-- | The time used and time left
254262
pTimes :: DrawData -> StringA
255263
pTimes DD { drawFrame=Just Frame {..}, drawSize=Size{sizeW=w} } =
256264
flip Fast defaultSty $ if w - 4 < P.length elapsed
257265
then ""
258-
else mconcat $ [" ", elapsed] ++ (guard (distance > 0) *> [gap, remaining])
266+
else mconcat $ [" ", elapsed] ++ [gap <> "-" <> remaining | distance > 0]
259267
where
260-
elapsed = P.pack $ printf "%d:%02d" l_m l_s
261-
remaining = P.pack $ printf "-%d:%02d" r_m r_s
262-
(l_m, l_s) = toMS currentTime
263-
(r_m, r_s) = toMS timeLeft
264-
gap = spaces distance
265-
distance = w - 4 - P.length elapsed - P.length remaining
266-
toMS :: RealFrac a => a -> (Int, Int)
267-
toMS = flip quotRem 60 . floor
268+
elapsed = showClock currentTime
269+
remaining = showClock timeLeft
270+
gap = spaces distance
271+
distance = w - 5 - P.length elapsed - P.length remaining
268272
pTimes _ = Fast "" defaultSty
269273

270274
------------------------------------------------------------------------

0 commit comments

Comments
 (0)