factor out another function

This commit is contained in:
Joey Hess 2018-10-29 23:33:56 -04:00
parent 2e9f128dea
commit 3d1b22dc8e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -22,8 +22,11 @@ import System.Locale
{- Parses how POSIXTime shows itself: "1431286201.113452s" {- Parses how POSIXTime shows itself: "1431286201.113452s"
- Also handles the format with no fractional seconds. -} - Also handles the format with no fractional seconds. -}
parsePOSIXTime :: String -> Maybe POSIXTime parsePOSIXTime :: String -> Maybe POSIXTime
parsePOSIXTime s = do parsePOSIXTime = uncurry parsePOSIXTime' . separate (== '.')
let (sn, sd) = separate (== '.') s
{- Parses the integral and decimal part of a POSIXTime -}
parsePOSIXTime' :: String -> String -> Maybe POSIXTime
parsePOSIXTime' sn sd = do
n <- readi sn n <- readi sn
if null sd if null sd
then return (fromIntegral n) then return (fromIntegral n)