]> gitweb.michael.orlitzky.com - dead/htsn-import.git/commitdiff
Combine the odds game date/time into one DB field.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 15 Jan 2014 02:28:07 +0000 (21:28 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 15 Jan 2014 02:28:07 +0000 (21:28 -0500)
src/TSN/XML/Odds.hs

index 467dbcf8ee6df3bf69241f35e5bad97cff2a3e1d..bbed4af08def3425c9ad550ba28836e60d41faf8 100644 (file)
@@ -27,7 +27,7 @@ where
 
 -- System imports.
 import Control.Monad ( forM_, join )
-import Data.Time ( UTCTime )
+import Data.Time ( UTCTime(..) )
 import Data.Tuple.Curry ( uncurryN )
 import Database.Groundhog (
   (=.),
@@ -257,8 +257,7 @@ data OddsGameLine =
 data OddsGame =
   OddsGame {
     db_game_id           :: Int,
-    db_game_date         :: UTCTime,
-    db_game_time         :: UTCTime,
+    db_game_time         :: UTCTime, -- ^ Contains both the date and time.
     db_game_away_team_rotation_number :: Int,
     db_game_home_team_rotation_number :: Int }
   deriving (Eq, Show)
@@ -268,8 +267,8 @@ data OddsGame =
 data OddsGameXml =
   OddsGameXml {
     xml_game_id         :: Int,
-    xml_game_date       :: UTCTime,
-    xml_game_time       :: UTCTime,
+    xml_game_date       :: UTCTime, -- ^ Contains only the date
+    xml_game_time       :: UTCTime, -- ^ Contains only the time
     xml_game_away_team  :: OddsGameAwayTeamXml,
     xml_game_home_team  :: OddsGameHomeTeamXml,
     xml_game_over_under :: OddsGameOverUnderXml }
@@ -295,10 +294,14 @@ instance FromXml OddsGameXml where
   from_xml OddsGameXml{..} =
     OddsGame {
       db_game_id   = xml_game_id,
-      db_game_date = xml_game_date,
-      db_game_time = xml_game_time,
+
+      db_game_time = UTCTime
+                       (utctDay xml_game_date) -- Take the day part from one,
+                       (utctDayTime xml_game_time), -- the time from the other.
+
       db_game_away_team_rotation_number =
         (xml_away_rotation_number xml_game_away_team),
+
       db_game_home_team_rotation_number =
         (xml_home_rotation_number xml_game_home_team) }