X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhtsn-import.git;a=blobdiff_plain;f=src%2FTSN%2FParse.hs;h=54175d762ed52ca72052fcb297dd632d30087eee;hp=0d497b4fea4361c08202accf77e9e2c634013644;hb=6eb1c7477c2d4d3cace6d1b865a5efbec21300a7;hpb=f1ec53a41f9d1fc0761a92476e20f214b9b75d79 diff --git a/src/TSN/Parse.hs b/src/TSN/Parse.hs index 0d497b4..54175d7 100644 --- a/src/TSN/Parse.hs +++ b/src/TSN/Parse.hs @@ -8,7 +8,7 @@ module TSN.Parse ( where import Data.Either.Utils ( maybeToEither ) -import Data.Time.Clock ( NominalDiffTime, UTCTime, addUTCTime ) +import Data.Time.Clock ( UTCTime ) import Data.Time.Format ( parseTime ) import System.Locale ( defaultTimeLocale ) import Text.Read ( readMaybe ) @@ -89,27 +89,27 @@ parse_xmlfid xmltree = time_format :: String time_format = "%I:%M %p" --- | The format string for a time_stamp. This omits the leading and --- trailing space. + +-- | The format string for a time_stamp. We keep the leading/trailing +-- space so that parseTime and formatTime are inverses are one +-- another, even though there is some confusion as to how these two +-- functions should behave: +-- +-- +-- time_stamp_format :: String -time_stamp_format = "%B %-d, %Y, at " ++ time_format ++ " ET" +time_stamp_format = " %B %-d, %Y, at " ++ time_format ++ " ET " --- | Parse a time stamp from a 'String' (maybe). --- --- 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 five hours to convert to UTC. + +-- | Parse a time stamp from a 'String' (maybe). TSN doesn't provide a +-- proper time zone name, so we parse it as UTC, and maybe our +-- eventual consumer can figure out a way to deduce the time zone. -- parse_time_stamp :: String -> Maybe UTCTime parse_time_stamp = - fmap add_five . parseTime defaultTimeLocale time_stamp_format - where - five_hours :: NominalDiffTime - five_hours = 5 * 60 * 60 + parseTime defaultTimeLocale time_stamp_format - add_five :: UTCTime -> UTCTime - add_five = addUTCTime five_hours -- | Extract the \"time_stamp\" element from a document. If we fail