Using elm-format for all files

This commit is contained in:
Eike Kettner
2019-12-29 21:55:12 +01:00
parent 546f1a6ee3
commit 2001cca88b
84 changed files with 7668 additions and 5079 deletions

View File

@ -2,46 +2,65 @@ module Util.Duration exposing (Duration, toHuman)
-- 486ms -> 12s -> 1:05 -> 59:45 -> 1:02:12
type alias Duration = Int
toHuman: Duration -> String
type alias Duration =
Int
toHuman : Duration -> String
toHuman dur =
fromMillis dur
-- implementation
fromMillis: Int -> String
fromMillis : Int -> String
fromMillis ms =
case ms // 1000 of
0 ->
(String.fromInt ms) ++ "ms"
String.fromInt ms ++ "ms"
n ->
fromSeconds n
fromSeconds: Int -> String
fromSeconds : Int -> String
fromSeconds sec =
case sec // 60 of
0 ->
(String.fromInt sec) ++ "s"
String.fromInt sec ++ "s"
n ->
let
s = sec - (n * 60)
s =
sec - (n * 60)
in
(fromMinutes n) ++ ":" ++ (num s)
fromMinutes n ++ ":" ++ num s
fromMinutes: Int -> String
fromMinutes : Int -> String
fromMinutes min =
case min // 60 of
0 ->
(num min)
num min
n ->
let
m = min - (n * 60)
m =
min - (n * 60)
in
(num n) ++ ":" ++ (num m)
num n ++ ":" ++ num m
num: Int -> String
num : Int -> String
num n =
String.fromInt n
|> (++) (if n < 10 then "0" else "")
|> (++)
(if n < 10 then
"0"
else
""
)