xsd 0.3.6 → 0.3.7
raw patch · 3 files changed
+27/−14 lines, 3 files
Files
- LICENSE +1/−0
- Text/XML/XSD/DateTime.hs +22/−10
- xsd.cabal +4/−4
LICENSE view
@@ -1,4 +1,5 @@ Copyright 2009 Tony Morris+Copyright 2013 Stefan Wehr All rights reserved.
Text/XML/XSD/DateTime.hs view
@@ -25,6 +25,16 @@ -- | XSD @dateTime@ data structure <http://www.w3.org/TR/xmlschema-2/#dateTime> data DateTime = DateTime Bool Int Int Int Int Int Int (Maybe String) Offset +dateTimeConstr :: Bool+ -> Int+ -> Int+ -> Int+ -> Int+ -> Int+ -> Int+ -> Maybe [Char]+ -> Offset+ -> DateTime dateTimeConstr neg yy mm dd hhh mmm sss ssss tz = DateTime neg yy mm dd hhh mmm sss (fmap (filter isDigit) ssss) tz instance Show DateTime where@@ -109,8 +119,10 @@ timeZone _ = error "Offset invariant not met" seconds :: Maybe String -> String-seconds (Just "") = []-seconds (Just d) = '.' : d+seconds (Just s) =+ case s of+ "" -> []+ _ -> '.' : s seconds Nothing = [] showi :: (Show a, Num a, Ord a) => a -> String@@ -125,7 +137,7 @@ z = const (Offset True Nothing Nothing Nothing) `fmap` char 'Z' o = do neg <- fmap (== '-') (char '+' <|> char '-') hh <- p2imax 14- char ':'+ _ <- char ':' mm <- p2imax (if hh == 14 then 0 else 59) return (Offset False (Just neg) (Just hh) (Just mm)) in e <|> z <|> o@@ -133,15 +145,15 @@ parseDateTime :: GenParser Char st DateTime parseDateTime = do neg <- isJust `fmap` optionMaybe (char '-') yy <- yearParser- char '-'+ _ <- char '-' mm <- p2imax 12- char '-'- dd <- p2imax ([31, if isLeapYear (fromIntegral mm) then 29 else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] !! (mm - 1))- char 'T'+ _ <- char '-'+ dd <- p2imax ([31, if isLeapYear (fromIntegral yy) then 29 else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] !! (mm - 1))+ _ <- char 'T' hhh <- p2imax 23- char ':'+ _ <- char ':' mmm <- p2imax 59- char ':'+ _ <- char ':' sss <- p2imax 59 ssss <- optionMaybe fractionalSeconds o <- parseOffset@@ -158,7 +170,7 @@ else return (read ([d1, d2, d3, d4] ++ ds)) fractionalSeconds :: GenParser Char st String-fractionalSeconds = do char '.'+fractionalSeconds = do _ <- char '.' many1 digit p2imax :: Int -> GenParser Char st Int
xsd.cabal view
@@ -1,14 +1,14 @@ Name: xsd-Version: 0.3.6+Version: 0.3.7 License: BSD3 License-File: LICENSE Synopsis: XML Schema data structures Description: XML Schema data structures (XSD)-Homepage: http://code.google.com/p/data-xsd/+Homepage: https://github.com/skogsbaer/xsd Category: XML Author: Tony Morris-Maintainer: code@tmorris.net-Copyright: 2010 Tony Morris+Maintainer: Stefan Wehr <wehr@factisresearch.com>+Copyright: 2010 Tony Morris, 2013 Stefan Wehr build-type: Simple cabal-version: >= 1.2