summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Travel/Status/DE/IRIS.pm12
-rw-r--r--t/20-iris-class.t2
-rw-r--r--t/31-result-basics.t6
3 files changed, 11 insertions, 9 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index e257c67..21bc599 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -131,10 +131,11 @@ sub new {
}
@{ $self->{results} } = grep {
- my $d
- = ( $_->departure // $_->arrival )
- ->subtract_datetime( $self->{datetime} );
- not $d->is_negative and $d->in_units('minutes') < $self->{lookahead}
+ my $d = ( $_->departure // $_->arrival );
+ my $sd = $_->sched_departure // $_->sched_arrival // $d;
+ $d = $d->subtract_datetime( $self->{datetime} );
+ $sd = $sd->subtract_datetime( $self->{datetime} );
+ not $d->is_negative and $sd->in_units('minutes') < $self->{lookahead}
} @{ $self->{results} };
@{ $self->{results} }
@@ -607,7 +608,8 @@ IRIS base url, defaults to C<< http://iris.noncd.db.de/iris-tts/timetable >>.
=item B<lookahead> => I<int>
-Compute only results which are less than I<int> minutes in the future.
+Compute only results which are scheduled less than I<int> minutes in the
+future.
Default: 180 (3 hours).
Note that the DeutscheBahn IRIS backend only provides schedules up to four to
diff --git a/t/20-iris-class.t b/t/20-iris-class.t
index a861909..65a2d60 100644
--- a/t/20-iris-class.t
+++ b/t/20-iris-class.t
@@ -4,7 +4,7 @@ use warnings;
use 5.014;
use DateTime;
-use Test::More tests => 266;
+use Test::More tests => 268;
BEGIN {
use_ok('Travel::Status::DE::IRIS');
diff --git a/t/31-result-basics.t b/t/31-result-basics.t
index c7210a4..4468a53 100644
--- a/t/31-result-basics.t
+++ b/t/31-result-basics.t
@@ -5,7 +5,7 @@ use 5.014;
use utf8;
use DateTime;
-use Test::More tests => 429;
+use Test::More tests => 432;
use Test::Fatal;
use Travel::Status::DE::IRIS;
@@ -26,7 +26,7 @@ my $status = Travel::Status::DE::IRIS->new(
my @results = $status->results;
-is(@results, 131, 'got 131 results');
+is(scalar @results, 132, 'got 132 results');
my $ice645 = $results[0];
my $s1 = $results[1];
@@ -113,4 +113,4 @@ $status = Travel::Status::DE::IRIS->new(
@results = $status->results;
-is(@results, 0, 'lookahead 0 -> no results');
+is(scalar @results, 10, 'lookahead 0 -> only overdue results');