parse "5" as 5 seconds

This commit is contained in:
Joey Hess 2013-10-26 12:07:00 -04:00
parent 323fb55a31
commit 4830c0d830

View file

@ -35,9 +35,11 @@ parseDuration = Duration <$$> go 0
go n [] = return n
go n s = do
num <- readish s :: Maybe Integer
let (c:rest) = dropWhile isDigit s
u <- M.lookup c unitmap
go (n + num * u) rest
case dropWhile isDigit s of
(c:rest) -> do
u <- M.lookup c unitmap
go (n + num * u) rest
_ -> return $ n + num
fromDuration :: Duration -> String
fromDuration Duration { durationSeconds = d }