summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-10-06 19:28:00 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-10-06 19:28:00 +0200
commite8ff730320dc53846d74f3568936b272990cabff (patch)
tree35a3b0ac43c259fa5f9ad62ccdce96cfd523ee73 /lib/Travelynx.pm
parenta6bbd6302c798995227190bfe7f8a5e7288ff80f (diff)
Stats: Fix handling of negative cumulative arrival/departure delays1.18.1
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-xlib/Travelynx.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 32b6b6d..a5dbcb8 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -2781,7 +2781,7 @@ sub startup {
}
$next_departure = $journey->{rt_dep_ts};
}
- return {
+ my $ret = {
km_route => $km_route,
km_beeline => $km_beeline,
num_trains => $num_trains,
@@ -2793,6 +2793,21 @@ sub startup {
delay_arr => $delay_arr,
inconsistencies => \@inconsistencies,
};
+ for my $key (
+ qw(min_travel_sched min_travel_real min_interchange_real delay_dep delay_arr)
+ )
+ {
+ my $strf_key = $key . '_strf';
+ my $value = $ret->{$key};
+ $ret->{$strf_key} = q{};
+ if ( $ret->{$key} < 0 ) {
+ $ret->{$strf_key} .= '-';
+ $value *= -1;
+ }
+ $ret->{$strf_key}
+ .= sprintf( '%02d:%02d', $value / 60, $value % 60 );
+ }
+ return $ret;
}
);