summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-11-09 19:28:48 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-11-09 19:28:48 +0100
commitdf74dd5cf97b73cfb6c63fd7399eb273c92f661f (patch)
treed4cc216d73e3c4cb0a5b88787f56fe74420bee72 /lib/Travelynx.pm
parent0a37788fef9883441721e8481099c1e49c4ee6d5 (diff)
route: handle stops without real-time data
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-xlib/Travelynx.pm27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 9121cd9..f6e47a3 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -1528,29 +1528,34 @@ sub startup {
for my $station (@route_after) {
if ( @{$station} > 1 ) {
- # Note: $station->[1]{sched_arr} may already have been
- # converted to a DateTime object in $station->[1] is
- # $dep_info. This can happen when a station is present
- # several times in a train's route, e.g. for Frankfurt
- # Flughafen in some nightly connections.
+ # Note: $station->[1]{sched_arr} may already have been
+ # converted to a DateTime object. This can happen when a
+ # station is present several times in a train's route, e.g.
+ # for Frankfurt Flughafen in some nightly connections.
my $times = $station->[1];
if ( $times->{sched_arr}
and ref( $times->{sched_arr} ) ne 'DateTime' )
{
$times->{sched_arr}
= epoch_to_dt( $times->{sched_arr} );
- $times->{rt_arr} = epoch_to_dt( $times->{rt_arr} );
- $times->{rt_arr_countdown}
- = $times->{rt_arr}->epoch - $epoch;
+ if ( $times->{rt_arr} ) {
+ $times->{rt_arr}
+ = epoch_to_dt( $times->{rt_arr} );
+ $times->{rt_arr_countdown}
+ = $times->{rt_arr}->epoch - $epoch;
+ }
}
if ( $times->{sched_dep}
and ref( $times->{sched_dep} ) ne 'DateTime' )
{
$times->{sched_dep}
= epoch_to_dt( $times->{sched_dep} );
- $times->{rt_dep} = epoch_to_dt( $times->{rt_dep} );
- $times->{rt_dep_countdown}
- = $times->{rt_dep}->epoch - $epoch;
+ if ( $times->{rt_dep} ) {
+ $times->{rt_dep}
+ = epoch_to_dt( $times->{rt_dep} );
+ $times->{rt_dep_countdown}
+ = $times->{rt_dep}->epoch - $epoch;
+ }
}
}
}