summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-02-06 19:13:35 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-02-06 19:13:35 +0100
commit765bf0794a92522d13b75ced092ab0cfd8cdbf64 (patch)
tree8b12e123f4fffac8c9f1231dc30a8688224c49df /lib/Travel/Status/DE
parent822be4f5957a5f34a4542cfdf92c350953340151 (diff)
add lookahead option
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 2d4d068..03aa89c 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -30,7 +30,8 @@ sub new {
// DateTime->now( time_zone => 'Europe/Berlin' ),
iris_base => $opt{iris_base}
// 'http://iris.noncd.db.de/iris-tts/timetable',
- station => $opt{station},
+ lookahead => $opt{lookahead} // ( 4 * 60 ),
+ station => $opt{station},
user_agent => $ua,
};
@@ -68,7 +69,7 @@ sub new {
my $d
= ( $_->departure // $_->arrival )
->subtract_datetime( $self->{datetime} );
- not $d->is_negative and $d->in_units('hours') < 4
+ not $d->is_negative and $d->in_units('minutes') < $self->{lookahead}
} @{ $self->{results} };
@{ $self->{results} }
@@ -303,6 +304,18 @@ current date and time.
IRIS base url, defaults to C<< http://iris.noncd.db.de/iris-tts/timetable >>.
+=item B<lookahead> => I<int>
+
+Compute only those results which are less than I<int> minutes in the future.
+Default: 240 (4 hours).
+
+Note that the DeutscheBahn IRIS backend only provides schedules up to four
+to five hours into the future, and this module only requests data for up to
+three hours. So in most cases, setting this to a value above 180 minutes will
+have no effect. However, as the IRIS occasionally contains unscheduled
+departures or qos messages known far in advance (e.g. 12 hours from now), any
+non-negative integer is accepted.
+
=item B<station> => I<stationcode>
Mandatory: Which station to return departures for. Note that this is not a