Fix API changes in time
package between 7.8/7.10
This commit is contained in:
parent
070fe26831
commit
a73a4fca93
3 changed files with 18 additions and 2 deletions
|
@ -65,7 +65,7 @@ library
|
|||
, wai >= 3.0 && < 3.1
|
||||
, wai-app-static >= 3.0 && < 3.2
|
||||
, warp >= 3.0 && < 3.2
|
||||
, time >= 1.5 && < 1.6
|
||||
, time >= 1.4 && < 1.6
|
||||
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
|
|
|
@ -59,7 +59,11 @@ library
|
|||
, string-conversions >= 0.3 && < 0.5
|
||||
, network-uri >= 2.6
|
||||
, vault >= 0.3 && <0.4
|
||||
, time >= 1.5 && < 1.6
|
||||
if impl(ghc < 7.10)
|
||||
build-depends: old-locale >= 1.0 && < 1.1
|
||||
, time >= 1.4 && < 1.5
|
||||
else
|
||||
build-depends: time >= 1.5 && < 1.6
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
other-extensions: CPP
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
|
@ -18,6 +19,9 @@ import Data.Typeable (Typeable)
|
|||
import GHC.TypeLits -- (Symbol)
|
||||
import Web.HttpApiData
|
||||
import qualified Data.Time.Format as T
|
||||
#if !MIN_VERSION_time(1,5,0)
|
||||
import System.Locale as T
|
||||
#endif
|
||||
import Data.Text (pack, Text)
|
||||
import Data.Proxy
|
||||
import Control.Monad ((>=>))
|
||||
|
@ -40,7 +44,11 @@ instance (KnownSymbol format, T.ParseTime t) => Read (FTime format t) where
|
|||
where
|
||||
res = fmap (first FTime)
|
||||
(readParen (i > 1)
|
||||
#if !MIN_VERSION_time(1,5,0)
|
||||
(T.readsTime T.defaultTimeLocale fmt)
|
||||
#else
|
||||
(T.readSTime False T.defaultTimeLocale fmt)
|
||||
#endif
|
||||
str
|
||||
)
|
||||
|
||||
|
@ -75,7 +83,11 @@ renderTime tt@(FTime t) = T.formatTime T.defaultTimeLocale (getFormat tt) t
|
|||
parseTime :: (KnownSymbol format, T.ParseTime t) => String -> Either Text (FTime format t)
|
||||
parseTime str = res
|
||||
where
|
||||
#if !MIN_VERSION_time(1,5,0)
|
||||
res = case T.parseTime T.defaultTimeLocale fmt str of
|
||||
#else
|
||||
res = case T.parseTimeM False T.defaultTimeLocale fmt str of
|
||||
#endif
|
||||
Nothing -> Left . pack $ "Could not parse time string \"" ++ str ++ "\" with format \"" ++ fmt ++ "\""
|
||||
Just t -> Right (FTime t)
|
||||
|
||||
|
|
Loading…
Reference in a new issue