]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/Parse.hs
Use UTC instead of EST to store the timestamps; they're both wrong anyway.
[dead/htsn-import.git] / src / TSN / Parse.hs
index 0d497b4fea4361c08202accf77e9e2c634013644..54175d762ed52ca72052fcb297dd632d30087eee 100644 (file)
@@ -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:
+--
+--   <https://ghc.haskell.org/trac/ghc/ticket/9150>
+--
 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