fix parsing of timestamp w/o trailing 's'
Luckily, this did not affect any git-annex log files, since they all include the trailing 's' for backwards compatability reasons. But, if I later want to drop that, this is the first commit where git-annex can be trusted to parse that right. The misparse caused it to be off by up to 10 seconds.
This commit is contained in:
parent
3d1b22dc8e
commit
a8ad577d1d
1 changed files with 4 additions and 3 deletions
|
@ -28,11 +28,12 @@ parsePOSIXTime = uncurry parsePOSIXTime' . separate (== '.')
|
||||||
parsePOSIXTime' :: String -> String -> Maybe POSIXTime
|
parsePOSIXTime' :: String -> String -> Maybe POSIXTime
|
||||||
parsePOSIXTime' sn sd = do
|
parsePOSIXTime' sn sd = do
|
||||||
n <- readi sn
|
n <- readi sn
|
||||||
if null sd
|
let sd' = takeWhile (/= 's') sd
|
||||||
|
if null sd'
|
||||||
then return (fromIntegral n)
|
then return (fromIntegral n)
|
||||||
else do
|
else do
|
||||||
d <- readi sd
|
d <- readi sd'
|
||||||
let r = d % (10 ^ (length sd - 1))
|
let r = d % (10 ^ (length sd'))
|
||||||
return (fromIntegral n + fromRational r)
|
return (fromIntegral n + fromRational r)
|
||||||
where
|
where
|
||||||
readi :: String -> Maybe Integer
|
readi :: String -> Maybe Integer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue