summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-01-28 18:50:54 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-01-28 18:50:54 +0100
commitc6b1f38efbc1029ee54ea396c300a2e62f6607c1 (patch)
tree913279582fc11e33a292f68b5aef18a8dc1c9eea /lib/Travel
parent281f534570991487787e12cd7d2b081a835c4d97 (diff)
Support ->lookbehind for delayed trains from previous hours
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 5bb0b89..bbb84c7 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -35,9 +35,10 @@ sub new {
developer_mode => $opt{developer_mode},
iris_base => $opt{iris_base}
// 'http://iris.noncd.db.de/iris-tts/timetable',
- lookahead => $opt{lookahead} // ( 4 * 60 ),
- main_cache => $opt{main_cache},
- rt_cache => $opt{realtime_cache},
+ lookahead => $opt{lookahead} // ( 4 * 60 ),
+ lookbehind => $opt{lookbehind} // ( 0 * 60 ),
+ main_cache => $opt{main_cache},
+ rt_cache => $opt{realtime_cache},
serializable => $opt{serializable},
user_agent => $ua,
with_related => $opt{with_related},
@@ -67,6 +68,7 @@ sub new {
datetime => $self->{datetime},
developer_mode => $self->{developer_mode},
lookahead => $self->{lookahead},
+ lookbehind => $self->{lookbehind},
station => $ref->{uic},
main_cache => $self->{main_cache},
realtime_cache => $self->{rt_cache},
@@ -82,10 +84,15 @@ sub new {
}
my $dt_req = $self->{datetime}->clone;
- for ( 1 .. 3 ) {
+ for ( 1 .. int( $self->{lookahead} / 60 ) ) {
$self->get_timetable( $self->{station}{uic}, $dt_req );
$dt_req->add( hours => 1 );
}
+ $dt_req = $self->{datetime}->clone;
+ for ( 1 .. int( $self->{lookbehind} / 60 ) ) {
+ $dt_req->subtract( hours => 1 );
+ $self->get_timetable( $self->{station}{uic}, $dt_req );
+ }
$self->get_realtime;