aboutsummaryrefslogtreecommitdiff
path: root/lib/GTFS.hs
diff options
context:
space:
mode:
authorstuebinm2022-12-03 14:27:49 +0100
committerstuebinm2022-12-03 14:39:38 +0100
commite84f2967a3252f474d9618fb19df6f571c3bc762 (patch)
tree0c2e2678cb597161290b69a4fcf65e5a4d516128 /lib/GTFS.hs
parenta9a13ca492ab3b8f8357cbe8fdec8a4052da913e (diff)
unreasonably stupid and probably unnecessary code
(but maybe google will like it)
Diffstat (limited to 'lib/GTFS.hs')
-rw-r--r--lib/GTFS.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/GTFS.hs b/lib/GTFS.hs
index 3935caa..b83db0f 100644
--- a/lib/GTFS.hs
+++ b/lib/GTFS.hs
@@ -127,6 +127,12 @@ toSeconds (Time seconds _ _) tzseries refday =
where timezone = timeZoneFromSeries tzseries reftime
reftime = UTCTime refday (fromInteger $ toInteger seconds)
+-- | convert a time to a UTCTime, using the timezone valid on the refday.
+-- Note that this will may fail to be correct in case of trips going across midnight
+toUTC :: Time -> TimeZoneSeries -> Day -> UTCTime
+toUTC time tzseries refday =
+ UTCTime refday (fromInteger $ toInteger $ unSeconds $ toSeconds time tzseries refday)
+
-- | Times in GTFS are given without timezone info, which is handled
-- seperately (as an attribute of the stop / the agency). We attach that information