@@ -15,11 +15,13 @@ import qualified Data.Vector as V
15import qualified Data.Set as S
15import qualified Data.Set as S
16import Control.Applicative (liftA, (<*), (*>), (<$>))
16import Control.Applicative (liftA, (<*), (*>), (<$>))
17import Data.Functor.Identity (Identity)
17import Data.Functor.Identity (Identity)
18−
18+import Data.Time.Format
20atomTypeP :: Parser AtomType
21atomTypeP :: Parser AtomType
21atomTypeP = (reserved "char" *> return StringAtomType) <|>
22atomTypeP = (reserved "char" *> return StringAtomType) <|>
22 (reserved "int" *> return IntAtomType) <|>
23 (reserved "int" *> return IntAtomType) <|>
24+ (reserved "datetime" *> return DateTimeAtomType) <|>
23 (RelationAtomType <$> (reserved "relation" *> makeAttributesP))
25 (RelationAtomType <$> (reserved "relation" *> makeAttributesP))
25--used in projection
27--used in projection
@@ -221,7 +223,7 @@ nakedAtomExprP :: Parser AtomExpr
221nakedAtomExprP = NakedAtomExpr <$> atomP
223nakedAtomExprP = NakedAtomExpr <$> atomP
223atomP :: Parser Atom
225atomP :: Parser Atom
224−atomP = stringAtomP <|> intAtomP <|> boolAtomP <|> relationAtomP
226+atomP = dateTimeAtomP <|> stringAtomP <|> intAtomP <|> boolAtomP <|> relationAtomP
226functionAtomExprP :: Parser AtomExpr
228functionAtomExprP :: Parser AtomExpr
227functionAtomExprP = do
229functionAtomExprP = do
@@ -237,7 +239,21 @@ quotedChar = noneOf "\""
237 <|> try (string "\"\"" >> return '"')
239 <|> try (string "\"\"" >> return '"')
239stringAtomP :: Parser Atom
241stringAtomP :: Parser Atom
240−stringAtomP = liftA (StringAtom . T.pack) (string "\"" *> many quotedChar <* string "\"")
242+stringAtomP = liftA (StringAtom . T.pack) quotedString
244+quotedString :: Parser String
245+quotedString = string "\"" *> many quotedChar <* string "\""
247+dateTimeAtomP :: Parser Atom
249+ dateString' <- try $ do
250+ dateString <- quotedString
253+ --deprecated in time 1.5- needs update for GHC 7.10
254+ case parseTime defaultTimeLocale "%Y-%m-%d %H:%M" dateString' of
255+ Just utctime -> return $ DateTimeAtom utctime
256+ Nothing -> fail "Failed to parse datetime"
242intAtomP :: Parser Atom
258intAtomP :: Parser Atom
243intAtomP = (IntAtom . fromIntegral) <$> integer
259intAtomP = (IntAtom . fromIntegral) <$> integer