1 module ParsecParserTest
7 import Data.Time.W3C hiding (parse)
8 import Data.Time.W3C.Parser.Parsec
13 parseW3C :: String -> Either String W3CDateTime
14 parseW3C src = case parse w3cDateTime "" src of
15 Left err -> Left (show err)
16 Right w3c -> Right w3c
18 parseW3C' :: String -> Maybe W3CDateTime
19 parseW3C' src = case parse w3cDateTime "" src of
25 testData = [ parseW3C "2010"
27 Right (W3CDateTime 2010 Nothing Nothing Nothing Nothing Nothing Nothing)
31 Right (W3CDateTime 2010 (Just 12) Nothing Nothing Nothing Nothing Nothing)
33 , parseW3C "2010-12-31"
35 Right (W3CDateTime 2010 (Just 12) (Just 31) Nothing Nothing Nothing Nothing)
37 , parseW3C "2010-12-31T01:23Z"
39 Right (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) Nothing (Just (hoursToTimeZone 0)))
41 , parseW3C "2010-12-31T01:23:45+09:00"
43 Right (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) (Just 45) (Just (hoursToTimeZone 9)))
45 , parseW3C "2010-12-31T01:23:45.666666+09:00"
47 Right (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) (Just 45.666666) (Just (hoursToTimeZone 9)))
53 , parseW3C' "99-01-01"
57 , parseW3C' "2010-01-01T"
61 , parseW3C' "2010-01-01T10Z"
65 , parseW3C' "2010-01-01T11:22"
69 , parseW3C' "2010-01-01T11:22:33"
73 , parseW3C' "2010-01-01T11:22:33.Z"