module Data.Aeson.Parser.Time (
run,
FT.parseDay,
FT.parseMonth,
FT.parseQuarter,
FT.parseQuarterOfYear,
FT.parseLocalTime,
FT.parseTimeOfDay,
FT.parseUTCTime,
FT.parseZonedTime,
) where
import Data.Text (Text)
import qualified Data.Aeson.Types.Internal as Aeson
import qualified Data.Time.FromText as FT
type Parser a = Text -> Either String a
run :: Parser a -> Text -> Aeson.Parser a
run :: forall a. Parser a -> Text -> Parser a
run Parser a
f Text
t = case Parser a
f Text
t of
Left String
err -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"could not parse date: " forall a. [a] -> [a] -> [a]
++ String
err
Right a
r -> forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINE run #-}