From 3d1b22dc8e1c91e3e7e47a802da97329c10ff734 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 29 Oct 2018 23:33:56 -0400 Subject: [PATCH] factor out another function --- Utility/TimeStamp.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Utility/TimeStamp.hs b/Utility/TimeStamp.hs index 0514529c24..cc9fcbc521 100644 --- a/Utility/TimeStamp.hs +++ b/Utility/TimeStamp.hs @@ -22,8 +22,11 @@ import System.Locale {- Parses how POSIXTime shows itself: "1431286201.113452s" - Also handles the format with no fractional seconds. -} parsePOSIXTime :: String -> Maybe POSIXTime -parsePOSIXTime s = do - let (sn, sd) = separate (== '.') s +parsePOSIXTime = uncurry parsePOSIXTime' . separate (== '.') + +{- Parses the integral and decimal part of a POSIXTime -} +parsePOSIXTime' :: String -> String -> Maybe POSIXTime +parsePOSIXTime' sn sd = do n <- readi sn if null sd then return (fromIntegral n)