more time-1.5 fixes
This commit is contained in:
parent
33a2264546
commit
6c2d5b5e41
3 changed files with 9 additions and 3 deletions
|
@ -16,7 +16,9 @@ import qualified Data.Set as S
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Data.Time.Format
|
import Data.Time.Format
|
||||||
|
#if ! MIN_VERSION_time(1,5,0)
|
||||||
import System.Locale
|
import System.Locale
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
|
|
@ -41,12 +41,11 @@ import qualified Annex.Branch
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Logs
|
import Logs
|
||||||
import Logs.SingleValue
|
import Logs.SingleValue
|
||||||
|
import Logs.TimeStamp
|
||||||
|
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import Data.Time.Format
|
|
||||||
import System.Locale
|
|
||||||
|
|
||||||
instance SingleValueSerializable MetaData where
|
instance SingleValueSerializable MetaData where
|
||||||
serialize = Types.MetaData.serialize
|
serialize = Types.MetaData.serialize
|
||||||
|
@ -86,7 +85,7 @@ getCurrentMetaData k = do
|
||||||
ts = lastchangedval l
|
ts = lastchangedval l
|
||||||
in M.map (const ts) m
|
in M.map (const ts) m
|
||||||
lastchangedval l = S.singleton $ toMetaValue $ showts $ changed l
|
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
|
{- Adds in some metadata, which can override existing values, or unset
|
||||||
- them, but otherwise leaves any existing metadata as-is. -}
|
- them, but otherwise leaves any existing metadata as-is. -}
|
||||||
|
|
|
@ -17,9 +17,14 @@ import System.Locale
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
|
{- Parses how POSIXTime shows itself: "1431286201.113452s"
|
||||||
|
- Also handles the format with no fractional seconds. -}
|
||||||
parsePOSIXTime :: String -> Maybe POSIXTime
|
parsePOSIXTime :: String -> Maybe POSIXTime
|
||||||
#if MIN_VERSION_time(1,5,0)
|
#if MIN_VERSION_time(1,5,0)
|
||||||
parsePOSIXTime s = utcTimeToPOSIXSeconds <$> parseTimeM True defaultTimeLocale "%s%Qs" s
|
parsePOSIXTime s = utcTimeToPOSIXSeconds <$> parseTimeM True defaultTimeLocale "%s%Qs" s
|
||||||
#else
|
#else
|
||||||
parsePOSIXTime s = utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" s
|
parsePOSIXTime s = utcTimeToPOSIXSeconds <$> parseTime defaultTimeLocale "%s%Qs" s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
formatPOSIXTime :: String -> POSIXTime -> String
|
||||||
|
formatPOSIXTime fmt t = formatTime defaultTimeLocale fmt (posixSecondsToUTCTime t)
|
||||||
|
|
Loading…
Reference in a new issue