@@ -15,11 +15,13 @@ import qualified Data.Vector as V
1515import qualified Data.Set as S
1616import Control.Applicative (liftA, (<*), (*>), (<$>))
1717import Data.Functor.Identity (Identity)
18−
18+import Data.Time.Format
19+import System.Locale
1920
2021atomTypeP :: Parser AtomType
2122atomTypeP = (reserved "char" *> return StringAtomType) <|>
2223 (reserved "int" *> return IntAtomType) <|>
24+ (reserved "datetime" *> return DateTimeAtomType) <|>
2325 (RelationAtomType <$> (reserved "relation" *> makeAttributesP))
2426
2527--used in projection
@@ -221,7 +223,7 @@ nakedAtomExprP :: Parser AtomExpr
221223nakedAtomExprP = NakedAtomExpr <$> atomP
222224
223225atomP :: Parser Atom
224−atomP = stringAtomP <|> intAtomP <|> boolAtomP <|> relationAtomP
226+atomP = dateTimeAtomP <|> stringAtomP <|> intAtomP <|> boolAtomP <|> relationAtomP
225227
226228functionAtomExprP :: Parser AtomExpr
227229functionAtomExprP = do
@@ -237,7 +239,21 @@ quotedChar = noneOf "\""
237239 <|> try (string "\"\"" >> return '"')
238240
239241stringAtomP :: Parser Atom
240−stringAtomP = liftA (StringAtom . T.pack) (string "\"" *> many quotedChar <* string "\"")
242+stringAtomP = liftA (StringAtom . T.pack) quotedString
243+
244+quotedString :: Parser String
245+quotedString = string "\"" *> many quotedChar <* string "\""
246+
247+dateTimeAtomP :: Parser Atom
248+dateTimeAtomP = do
249+ dateString' <- try $ do
250+ dateString <- quotedString
251+ reserved "::dt"
252+ return dateString
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"
241257
242258intAtomP :: Parser Atom
243259intAtomP = (IntAtom . fromIntegral) <$> integer