diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-07-02 18:38:32 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-07-02 18:38:32 +0200 |
commit | 242a6d2c472f0ff747db7665294fac19eaa2408e (patch) | |
tree | 8d110c5ac87aca67295b6544293c068d1c27ee81 /lib/Travel | |
parent | 4aee2fb6dc0755371eaa23459e514ac76f6a9576 (diff) | |
parent | f09d59986998f2210314e38a1ad72d77fcfac067 (diff) |
Merge branch 'master' of git.finalrewind.org:var/git_root/Travel-Status-DE-IRIS
Diffstat (limited to 'lib/Travel')
-rw-r--r-- | lib/Travel/Status/DE/IRIS.pm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index aab0788..43993b0 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -31,7 +31,7 @@ sub new { developer_mode => $opt{developer_mode}, iris_base => $opt{iris_base} // 'http://iris.noncd.db.de/iris-tts/timetable', - lookahead => $opt{lookahead} // ( 3 * 60 ), + lookahead => $opt{lookahead} // ( 2 * 60 ), lookbehind => $opt{lookbehind} // ( 0 * 60 ), main_cache => $opt{main_cache}, rt_cache => $opt{realtime_cache}, @@ -88,13 +88,25 @@ sub new { return $self; } + my $lookahead_steps = int( $self->{lookahead} / 60 ); + if ( ( 60 - $self->{datetime}->minute ) < ( $self->{lookahead} % 60 ) ) { + say "lookahead: ${lookahead_steps}++"; + $lookahead_steps++; + } + my $lookbehind_steps = int( $self->{lookbehind} / 60 ); + if ( $self->{datetime}->minute < ( $self->{lookbehind} % 60 ) ) { + say "lookbehind: ${lookbehind_steps}++"; + $lookbehind_steps++; + } + my $dt_req = $self->{datetime}->clone; - for ( 1 .. int( $self->{lookahead} / 60 ) ) { - $self->get_timetable( $self->{station}{uic}, $dt_req ); + $self->get_timetable( $self->{station}{uic}, $dt_req ); + for ( 1 .. $lookahead_steps ) { $dt_req->add( hours => 1 ); + $self->get_timetable( $self->{station}{uic}, $dt_req ); } $dt_req = $self->{datetime}->clone; - for ( 1 .. int( $self->{lookbehind} / 60 ) ) { + for ( 1 .. $lookbehind_steps ) { $dt_req->subtract( hours => 1 ); $self->get_timetable( $self->{station}{uic}, $dt_req ); } |