summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-10 21:30:57 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-10 21:34:05 +0100
commit3e96b9b5bf432196b50a6a4df9dba85c2ae889f9 (patch)
tree04faa820c877386996899fb4fc0413bddb2c5202
parent869aa460a5a17989dff6e30eb6486b1e7be31542 (diff)
lookahead: do not ignore trains where only arrival is < lookahead time
-rw-r--r--lib/Travel/Status/DE/IRIS.pm10
-rw-r--r--t/20-iris-class.t2
-rw-r--r--t/31-result-basics.t4
3 files changed, 8 insertions, 8 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 6d712de..733a73c 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -144,11 +144,11 @@ sub new {
}
@{ $self->{results} } = grep {
- 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}
+ my $d = $_->departure // $_->arrival;
+ my $s = $_->sched_arrival // $_->sched_departure // $_->arrival // $d;
+ $d = $d->subtract_datetime( $self->{datetime} );
+ $s = $s->subtract_datetime( $self->{datetime} );
+ not $d->is_negative and $s->in_units('minutes') < $self->{lookahead}
} @{ $self->{results} };
@{ $self->{results} }
diff --git a/t/20-iris-class.t b/t/20-iris-class.t
index 65a2d60..69e1c45 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 => 268;
+use Test::More tests => 270;
BEGIN {
use_ok('Travel::Status::DE::IRIS');
diff --git a/t/31-result-basics.t b/t/31-result-basics.t
index 4468a53..b587271 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 => 432;
+use Test::More tests => 435;
use Test::Fatal;
use Travel::Status::DE::IRIS;
@@ -26,7 +26,7 @@ my $status = Travel::Status::DE::IRIS->new(
my @results = $status->results;
-is(scalar @results, 132, 'got 132 results');
+is(scalar @results, 133, 'got 133 results');
my $ice645 = $results[0];
my $s1 = $results[1];