1 {-# LANGUAGE NoImplicitPrelude #-}
3 module Parsers.Date where
5 import Gargantext.Prelude
11 import Data.Either (Either(..))
12 import Data.Time (ZonedTime(..))
13 import Data.Text (pack, Text)
15 import Text.Parsec.Error (ParseError)
16 import Duckling.Time.Types (toRFC3339)
17 import Gargantext.Parsers.Date (fromRFC3339)
19 fromRFC3339Inv :: Either ParseError ZonedTime -> Text
20 fromRFC3339Inv (Right z) = toRFC3339 z
21 fromRFC3339Inv (Left pe) = pack $ show pe
23 testFromRFC3339 :: IO ()
24 testFromRFC3339 = hspec $ do
25 describe "Test fromRFC3339: " $ do
26 it "is the inverse of Duckling's toRFC3339" $ property $
27 \x -> (fromRFC3339 . fromRFC3339Inv) x == (x :: Either ParseError ZonedTime)