summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-10 15:36:58 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-10 15:36:58 -0400
commitcb994264d239ca4ac50402175a7fd7ac89e029d6 (patch)
tree4b7c4d05e045fc4593812746274b1898176cb216 /Logs
parent724e67bdf449120bdaf0ca695d49626e5249d446 (diff)
more time-1.5 fixes
Diffstat (limited to 'Logs')
-rw-r--r--Logs/MetaData.hs5
-rw-r--r--Logs/TimeStamp.hs5
2 files changed, 7 insertions, 3 deletions
diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs
index ed4e2363e..0dc76214c 100644
--- a/Logs/MetaData.hs
+++ b/Logs/MetaData.hs
@@ -41,12 +41,11 @@ import qualified Annex.Branch
import qualified Annex
import Logs
import Logs.SingleValue
+import Logs.TimeStamp
import qualified Data.Set as S
import qualified Data.Map as M
import Data.Time.Clock.POSIX
-import Data.Time.Format
-import System.Locale
instance SingleValueSerializable MetaData where
serialize = Types.MetaData.serialize
@@ -86,7 +85,7 @@ getCurrentMetaData k = do
ts = lastchangedval l
in M.map (const ts) m
lastchangedval l = S.singleton $ toMetaValue $ showts $ changed l
- showts = formatTime defaultTimeLocale "%F@%H-%M-%S" . posixSecondsToUTCTime
+ showts = formatPOSIXTime "%F@%H-%M-%S"
{- Adds in some metadata, which can override existing values, or unset
- them, but otherwise leaves any existing metadata as-is. -}
diff --git a/Logs/TimeStamp.hs b/Logs/TimeStamp.hs
index 121b76678..ca2670953 100644
--- a/Logs/TimeStamp.hs
+++ b/Logs/TimeStamp.hs
@@ -17,9 +17,14 @@ import System.Locale
import Common
+{- Parses how POSIXTime shows itself: "1431286201.113452s"
+ - Also handles the format with no fractional seconds. -}
parsePOSIXTime :: String -> Maybe POSIXTime
#if MIN_VERSION_time(1,5,0)
parsePOSIXTime s = utcTimeToPOSIXSeconds <$> parseTimeM True defaultTimeLocale "%s%Qs" s
#else
parsePOSIXTime s = utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" s
#endif
+
+formatPOSIXTime :: String -> POSIXTime -> String
+formatPOSIXTime fmt t = formatTime defaultTimeLocale fmt (posixSecondsToUTCTime t)