aboutsummaryrefslogtreecommitdiff
path: root/lib/GTFS.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/GTFS.hs')
-rw-r--r--lib/GTFS.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/GTFS.hs b/lib/GTFS.hs
index 9259649..bfb1c49 100644
--- a/lib/GTFS.hs
+++ b/lib/GTFS.hs
@@ -51,6 +51,7 @@ import Web.Internal.FormUrlEncoded (FromForm (..))
import Web.Internal.HttpApiData (FromHttpApiData (..))
-- import Data.Aeson.Generic (Options(fieldLabelModifier), deriveJSON, defaultOptions)
import Control.Lens
+import Control.Monad.IO.Class (MonadIO (liftIO))
import Data.Char (toLower)
import Data.Foldable (Foldable (fold))
import Data.Map (Map)
@@ -459,3 +460,12 @@ tripsAtStation GTFS{..} at = fmap stopTrip stops
tripsOnDay :: GTFS -> Day -> Map TripID (Trip Deep Deep)
tripsOnDay gtfs today = foldMap (tripsOfService gtfs) (servicesOnDay gtfs today)
+
+runsOnDay :: GTFS -> TripID -> Day -> Bool
+runsOnDay gtfs trip day = not . null . M.filter same $ tripsOnDay gtfs day
+ where same Trip{..} = tripTripID == trip
+
+runsToday :: MonadIO m => GTFS -> TripID -> m Bool
+runsToday gtfs trip = do
+ today <- liftIO getCurrentTime <&> utctDay
+ pure (runsOnDay gtfs trip today)