summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-01-17 20:26:26 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-01-17 20:26:26 +0100
commit5fe03ddd5e1c225fbe8906ec19076e1ef80aeee3 (patch)
tree95e870d1c2479204db5c9b0eeb0e59c5ee14f785 /lib/Travel/Status/DE
parentad6d575432fd47eb06de3e78f5c905112818f794 (diff)
Filter out realtime results which are >3 hours in the future
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 51b0051..e4a8dba 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -64,9 +64,12 @@ sub new {
$self->get_realtime;
- @{ $self->{results} }
- = grep { ( $_->departure // $_->arrival ) >= $self->{datetime} }
- @{ $self->{results} };
+ @{ $self->{results} } = grep {
+ my $d
+ = ( $_->departure // $_->arrival )
+ ->subtract_datetime( $self->{datetime} );
+ not $d->is_negative and $d->in_units('hours') < 4
+ } @{ $self->{results} };
@{ $self->{results} }
= sort { $a->{datetime} <=> $b->{datetime} } @{ $self->{results} };