diff options
author | stuebinm | 2022-08-14 15:43:37 +0200 |
---|---|---|
committer | stuebinm | 2022-08-14 15:43:37 +0200 |
commit | f13e72076dbdcf0cd53d8558fccbedb98b8ea492 (patch) | |
tree | 5f28fb4b575f85739933e0377c8e10e1fe63dfa2 /lib | |
parent | b4aaaf96f67fccae2dd284324215001384516a9b (diff) |
better Show instance for Time
Diffstat (limited to '')
-rw-r--r-- | lib/GTFS.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/GTFS.hs b/lib/GTFS.hs index 17dec72..9259649 100644 --- a/lib/GTFS.hs +++ b/lib/GTFS.hs @@ -92,9 +92,13 @@ instance CSV.FromField Time where instance Show Time where show (Time seconds) = "" - +|seconds `div` 3600|+":" - +|(seconds `mod` 3600) `div` 60|+":" - +|seconds `mod` 60|+"" + +|pad (seconds `div` 3600)|+":" + +|pad ((seconds `mod` 3600) `div` 60)|+ + if seconds `mod` 60 /= 0 then ":"+|pad (seconds `mod` 60)|+"" + else "" + where pad num = + if length str < 2 then "0"<>str else str + where str = show num instance CSV.FromField Day where parseField f = do |