{-# LANGUAGE CPP #-}
module Data.Time.Format.Compat (
FormatTime(),formatTime,
parseTimeM, parseTimeOrError,
readSTime, readPTime,
parseTime, readTime, readsTime,
ParseTime(),
TimeLocale(..),
defaultTimeLocale,
iso8601DateFormat,
rfc822DateFormat,
) where
import Data.Time.Orphans ()
import Data.Time.Format
#if !MIN_VERSION_time(1,5,0)
import System.Locale (TimeLocale, defaultTimeLocale, iso8601DateFormat, rfc822DateFormat)
import qualified Control.Monad.Fail as Fail
import Text.ParserCombinators.ReadP (readP_to_S, readS_to_P, ReadP)
parseTimeM
:: (Fail.MonadFail m, ParseTime t)
=> Bool
-> TimeLocale
-> String
-> String
-> m t
parseTimeM _acceptWS l fmt s = case parseTime l fmt s of
Just x -> return x
Nothing -> Fail.fail "parseTimeM: no parse"
parseTimeOrError
:: ParseTime t
=> Bool
-> TimeLocale
-> String
-> String
-> t
parseTimeOrError _acceptWS l fmt s = case parseTime l fmt s of
Just x -> x
Nothing -> error "parseTimeOrError: no parse"
readSTime :: ParseTime t =>
Bool
-> TimeLocale
-> String
-> ReadS t
readSTime _acceptWS l f = readsTime l f
readPTime :: ParseTime t =>
Bool
-> TimeLocale
-> String
-> ReadP t
readPTime acceptWS l f = readS_to_P (readSTime acceptWS l f)
#endif