From 765bf0794a92522d13b75ced092ab0cfd8cdbf64 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 6 Feb 2014 19:13:35 +0100 Subject: add lookahead option --- lib/Travel/Status/DE/IRIS.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/Travel/Status/DE') 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 => I + +Compute only those results which are less than I 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 => I Mandatory: Which station to return departures for. Note that this is not a -- cgit v1.2.3