+ from_time = formatTime defaultTimeLocale xp_time_format
+
+
+
+-- | (Un)pickle the \<time_stamp\> element format to/from a 'UTCTime'.
+--
+-- Example: \<time_stamp\> January 6, 2014, at 10:11 PM ET \</time_stamp\>
+--
+-- TSN doesn't provide a proper time zone name, so we assume that
+-- it's always Eastern Standard Time. EST is UTC-5, so we
+-- add/subtract 5 hours to convert to/from UTC.
+--
+xp_time_stamp :: PU UTCTime
+xp_time_stamp =
+ (to_time_stamp, from_time_stamp) `xpWrapMaybe` xpText
+ where
+ -- This omits the timezone and trailing space.
+ format = " %B %-d, %Y, at " ++ xp_time_format ++ " ET "
+
+ five_hours :: NominalDiffTime
+ five_hours = 5 * 60 * 60
+
+ add_five :: UTCTime -> UTCTime
+ add_five = addUTCTime five_hours
+
+ subtract_five :: UTCTime -> UTCTime
+ subtract_five = addUTCTime (-1 * five_hours)
+
+ to_time_stamp :: String -> Maybe UTCTime
+ to_time_stamp = fmap add_five . parseTime defaultTimeLocale format