From 5fe03ddd5e1c225fbe8906ec19076e1ef80aeee3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 17 Jan 2014 20:26:26 +0100 Subject: Filter out realtime results which are >3 hours in the future --- lib/Travel/Status/DE/IRIS.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/Travel/Status') 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} }; -- cgit v1.2.3