fix parse of negative posix time
Should never happen, but..
This commit is contained in:
parent
a8ad577d1d
commit
48af284872
1 changed files with 5 additions and 3 deletions
|
@ -27,14 +27,16 @@ parsePOSIXTime = uncurry parsePOSIXTime' . separate (== '.')
|
||||||
{- Parses the integral and decimal part of a POSIXTime -}
|
{- Parses the integral and decimal part of a POSIXTime -}
|
||||||
parsePOSIXTime' :: String -> String -> Maybe POSIXTime
|
parsePOSIXTime' :: String -> String -> Maybe POSIXTime
|
||||||
parsePOSIXTime' sn sd = do
|
parsePOSIXTime' sn sd = do
|
||||||
n <- readi sn
|
n <- fromIntegral <$> readi sn
|
||||||
let sd' = takeWhile (/= 's') sd
|
let sd' = takeWhile (/= 's') sd
|
||||||
if null sd'
|
if null sd'
|
||||||
then return (fromIntegral n)
|
then return n
|
||||||
else do
|
else do
|
||||||
d <- readi sd'
|
d <- readi sd'
|
||||||
let r = d % (10 ^ (length sd'))
|
let r = d % (10 ^ (length sd'))
|
||||||
return (fromIntegral n + fromRational r)
|
return $ if n < 0
|
||||||
|
then n - fromRational r
|
||||||
|
else n + fromRational r
|
||||||
where
|
where
|
||||||
readi :: String -> Maybe Integer
|
readi :: String -> Maybe Integer
|
||||||
readi = readish
|
readi = readish
|
||||||
|
|
Loading…
Reference in a new issue