diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-02-06 19:13:35 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-02-06 19:13:35 +0100 |
commit | 765bf0794a92522d13b75ced092ab0cfd8cdbf64 (patch) | |
tree | 8b12e123f4fffac8c9f1231dc30a8688224c49df /lib/Travel | |
parent | 822be4f5957a5f34a4542cfdf92c350953340151 (diff) |
add lookahead option
Diffstat (limited to 'lib/Travel')
-rw-r--r-- | lib/Travel/Status/DE/IRIS.pm | 17 |
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 |