From 2e14c2e3e4dafa976cecab2721682553d90eb01e Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 7 Sep 2023 21:19:43 +0200 Subject: Fix intermediate stop display for journeys without real-time data, e.g. H-Bahn --- lib/Travelynx.pm | 26 +++++++++++--------------- lib/Travelynx/Model/InTransit.pm | 12 ++++++++---- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 64a1e85..a6080b2 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1593,21 +1593,17 @@ sub startup { for my $station ( @{ $journey->{route_after} } ) { my $station_desc = $station->[0]; - if ( $station->[2]{sched_arr} and $station->[2]{rt_arr} ) { - $station_desc .= $station->[2]{sched_arr}->strftime(';%s'); - $station_desc .= $station->[2]{rt_arr}->strftime(';%s'); - if ( $station->[2]{sched_dep} and $station->[2]{rt_dep} ) { - $station_desc - .= $station->[2]{sched_dep}->strftime(';%s'); - $station_desc .= $station->[2]{rt_dep}->strftime(';%s'); - } - else { - $station_desc .= ';0;0'; - } - } - else { - $station_desc .= ';0;0;0;0'; - } + + my $sa = $station->[2]{sched_arr}; + my $ra = $station->[2]{rt_arr} || $station->[2]{sched_arr}; + my $sd = $station->[2]{sched_dep}; + my $rd = $station->[2]{rt_dep} || $station->[2]{sched_dep}; + + $station_desc .= $sa ? $sa->strftime(';%s') : ';0'; + $station_desc .= $ra ? $ra->strftime(';%s') : ';0'; + $station_desc .= $sd ? $sd->strftime(';%s') : ';0'; + $station_desc .= $rd ? $rd->strftime(';%s') : ';0'; + push( @route, $station_desc ); } diff --git a/lib/Travelynx/Model/InTransit.pm b/lib/Travelynx/Model/InTransit.pm index aec193f..d06b94e 100644 --- a/lib/Travelynx/Model/InTransit.pm +++ b/lib/Travelynx/Model/InTransit.pm @@ -270,9 +270,11 @@ sub postprocess { if ( $times->{rt_arr} ) { $times->{rt_arr} = epoch_to_dt( $times->{rt_arr} ); - $times->{rt_arr_countdown} - = $times->{rt_arr}->epoch - $epoch; + $times->{arr_delay} + = $times->{rt_arr}->epoch - $times->{sched_arr}->epoch; } + $times->{arr} = $times->{rt_arr} || $times->{sched_arr}; + $times->{arr_countdown} = $times->{arr}->epoch - $epoch; } if ( $times->{sched_dep} and ref( $times->{sched_dep} ) ne 'DateTime' ) @@ -282,9 +284,11 @@ sub postprocess { if ( $times->{rt_dep} ) { $times->{rt_dep} = epoch_to_dt( $times->{rt_dep} ); - $times->{rt_dep_countdown} - = $times->{rt_dep}->epoch - $epoch; + $times->{dep_delay} + = $times->{rt_dep}->epoch - $times->{sched_dep}->epoch; } + $times->{dep} = $times->{rt_dep} || $times->{sched_dep}; + $times->{dep_countdown} = $times->{dep}->epoch - $epoch; } } } -- cgit v1.2.3