{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module System.Log.FastLogger.Date
(
newTimeCache
, simpleTimeFormat
, simpleTimeFormat'
) where
import Control.AutoUpdate (mkAutoUpdate, defaultUpdateSettings, updateAction)
import System.Log.FastLogger.Types (TimeFormat, FormattedTime)
import Data.UnixTime (formatUnixTime, fromEpochTime)
import System.PosixCompat.Types (EpochTime)
import System.PosixCompat.Time (epochTime)
getTime :: IO EpochTime
getTime :: IO EpochTime
getTime = IO EpochTime
epochTime
formatDate :: TimeFormat -> EpochTime -> IO FormattedTime
formatDate :: TimeFormat -> EpochTime -> IO TimeFormat
formatDate TimeFormat
fmt = TimeFormat -> UnixTime -> IO TimeFormat
formatUnixTime TimeFormat
fmt forall b c a. (b -> c) -> (a -> b) -> a -> c
. EpochTime -> UnixTime
fromEpochTime
newTimeCache :: TimeFormat -> IO (IO FormattedTime)
newTimeCache :: TimeFormat -> IO (IO TimeFormat)
newTimeCache TimeFormat
fmt = forall a. UpdateSettings a -> IO (IO a)
mkAutoUpdate UpdateSettings ()
defaultUpdateSettings{
updateAction :: IO TimeFormat
updateAction = IO EpochTime
getTime forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= TimeFormat -> EpochTime -> IO TimeFormat
formatDate TimeFormat
fmt
}
simpleTimeFormat :: TimeFormat
simpleTimeFormat :: TimeFormat
simpleTimeFormat = TimeFormat
"%d/%b/%Y:%T %z"
simpleTimeFormat' :: TimeFormat
simpleTimeFormat' :: TimeFormat
simpleTimeFormat' = TimeFormat
"%d-%b-%Y %T"