summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog4
-rw-r--r--lib/Travel/Status/DE/IRIS.pm15
-rw-r--r--t/20-iris-class.t3
-rw-r--r--t/31-result-basics.t3
4 files changed, 19 insertions, 6 deletions
diff --git a/Changelog b/Changelog
index 1ef3aba..0582395 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+git HEAD
+
+ * IRIS->new: Add optional argument lookbehind
+
Travel::Status::DE::IRIS 1.13 - Thu Jan 26 2017
* Fix support for line numbers, remove manual line map workaround
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;
diff --git a/t/20-iris-class.t b/t/20-iris-class.t
index ba3882b..8ec50ef 100644
--- a/t/20-iris-class.t
+++ b/t/20-iris-class.t
@@ -21,7 +21,8 @@ my $status = Travel::Status::DE::IRIS->new(
hour => 20,
minute => 1,
time_zone => 'Europe/Berlin',
- )
+ ),
+ lookahead => 3 * 60 + 59,
);
isa_ok( $status, 'Travel::Status::DE::IRIS' );
diff --git a/t/31-result-basics.t b/t/31-result-basics.t
index f88fa6f..ac2b23d 100644
--- a/t/31-result-basics.t
+++ b/t/31-result-basics.t
@@ -20,7 +20,8 @@ my $status = Travel::Status::DE::IRIS->new(
hour => 20,
minute => 1,
time_zone => 'Europe/Berlin'
- )
+ ),
+ lookahead => 3 * 60 + 59,
);
my @results = $status->results;