diff options
author | stuebinm | 2022-12-03 14:27:49 +0100 |
---|---|---|
committer | stuebinm | 2022-12-03 14:39:38 +0100 |
commit | e84f2967a3252f474d9618fb19df6f571c3bc762 (patch) | |
tree | 0c2e2678cb597161290b69a4fcf65e5a4d516128 /lib/Server | |
parent | a9a13ca492ab3b8f8357cbe8fdec8a4052da913e (diff) |
unreasonably stupid and probably unnecessary code
(but maybe google will like it)
Diffstat (limited to '')
-rw-r--r-- | lib/Server/GTFS_RT.hs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Server/GTFS_RT.hs b/lib/Server/GTFS_RT.hs index 20e6fa7..9da9be9 100644 --- a/lib/Server/GTFS_RT.hs +++ b/lib/Server/GTFS_RT.hs @@ -28,7 +28,8 @@ import Data.Text.Encoding (e import Data.Time.Calendar (Day, toGregorian) import Data.Time.Clock (UTCTime (utctDay), - getCurrentTime) + getCurrentTime, + addUTCTime) import Data.Time.Clock.POSIX (getPOSIXTime) import Data.Time.Clock.System (SystemTime (systemSeconds), getSystemTime, @@ -46,7 +47,7 @@ import GTFS (G Seconds (..), Stop (..), Trip (..), - stationId, + stationId, toUTC, TripID, tripsOnDay) import GTFS.Realtime.Alert as AL (Alert (..)) @@ -110,7 +111,7 @@ toStupidDate date = toUtf8 where ndigits = length (show num) -- | basically unix timestamps, raw (because why not i guess) -toStupidTime :: UTCTime -> Word64 +toStupidTime :: Num i => UTCTime -> i toStupidTime = fromIntegral . systemSeconds . utcToSystemTime gtfsRealtimeServer :: GTFS -> Pool SqlBackend -> Service GtfsRealtimeAPI @@ -171,9 +172,15 @@ gtfsRealtimeServer gtfs@GTFS{..} dbpool = handleServiceAlerts :<|> handleTripUpd { STU.stop_sequence = Just (fromIntegral stopSequence) , STU.stop_id = Just (toUtf8 $ stationId stopStation) , STU.arrival = Just ( - defaultValue { STE.delay = Just $ fromIntegral $ unSeconds $ trainAnchorDelay, STE.uncertainty = Just 60 }) + defaultValue + { STE.delay = Just $ fromIntegral $ unSeconds $ trainAnchorDelay + , STE.time = Just $ (toStupidTime (addUTCTime (fromIntegral $ unSeconds trainAnchorDelay) (toUTC stopArrival tzseries today))) + , STE.uncertainty = Just 60 }) , STU.departure = Just ( - defaultValue { STE.delay = Just $ fromIntegral $ unSeconds $ trainAnchorDelay, STE.uncertainty = Just 60 }) + defaultValue + { STE.delay = Just $ fromIntegral $ unSeconds $ trainAnchorDelay + , STE.time = Just $ (toStupidTime (addUTCTime (fromIntegral $ unSeconds trainAnchorDelay) (toUTC stopDeparture tzseries today))) + , STE.uncertainty = Just 60 }) , STU.departure_occupancy_status = Nothing , STU.schedule_relationship = Just SR.SCHEDULED , STU.stop_time_properties = Nothing |