diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-01-17 20:26:26 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-01-17 20:26:26 +0100 |
commit | 5fe03ddd5e1c225fbe8906ec19076e1ef80aeee3 (patch) | |
tree | 95e870d1c2479204db5c9b0eeb0e59c5ee14f785 /lib/Travel/Status/DE | |
parent | ad6d575432fd47eb06de3e78f5c905112818f794 (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.pm | 9 |
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} }; |