1 -- | (Un)picklers for data types present in The Sports Network XML
8 import Data.Time.Clock ( UTCTime )
9 import Data.Time.Format ( formatTime, parseTime )
10 import System.Locale ( defaultTimeLocale )
11 import Text.Read ( readMaybe )
12 import Text.XML.HXT.Arrow.Pickle (
16 import Text.XML.HXT.Arrow.Pickle.Xml ( PU )
18 instance XmlPickler Bool where
20 (to_bool, from_bool) `xpWrapMaybe` xpText
22 to_bool :: String -> Maybe Bool
25 from_bool :: Bool -> String
29 -- | (Un)pickle a UTCTime without the time portion.
33 (to_date, from_date) `xpWrapMaybe` xpText
37 to_date :: String -> Maybe UTCTime
38 to_date = parseTime defaultTimeLocale format
40 from_date :: UTCTime -> String
41 from_date = formatTime defaultTimeLocale format