parse "5" as 5 seconds
This commit is contained in:
parent
323fb55a31
commit
4830c0d830
1 changed files with 5 additions and 3 deletions
|
@ -35,9 +35,11 @@ parseDuration = Duration <$$> go 0
|
||||||
go n [] = return n
|
go n [] = return n
|
||||||
go n s = do
|
go n s = do
|
||||||
num <- readish s :: Maybe Integer
|
num <- readish s :: Maybe Integer
|
||||||
let (c:rest) = dropWhile isDigit s
|
case dropWhile isDigit s of
|
||||||
u <- M.lookup c unitmap
|
(c:rest) -> do
|
||||||
go (n + num * u) rest
|
u <- M.lookup c unitmap
|
||||||
|
go (n + num * u) rest
|
||||||
|
_ -> return $ n + num
|
||||||
|
|
||||||
fromDuration :: Duration -> String
|
fromDuration :: Duration -> String
|
||||||
fromDuration Duration { durationSeconds = d }
|
fromDuration Duration { durationSeconds = d }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue