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:
Joey Hess 2018-10-29 23:36:47 -04:00
parent 3d1b22dc8e
commit a8ad577d1d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -28,11 +28,12 @@ parsePOSIXTime = uncurry parsePOSIXTime' . separate (== '.')
parsePOSIXTime' :: String -> String -> Maybe POSIXTime
parsePOSIXTime' sn sd = do
n <- readi sn
if null sd
let sd' = takeWhile (/= 's') sd
if null sd'
then return (fromIntegral n)
else do
d <- readi sd
let r = d % (10 ^ (length sd - 1))
d <- readi sd'
let r = d % (10 ^ (length sd'))
return (fromIntegral n + fromRational r)
where
readi :: String -> Maybe Integer