From 022465d2a707e6752eca72be795363b06bffb1b3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 8 May 2019 07:12:54 +0200 Subject: Fix division by zero when calculating journey completion --- lib/Travelynx.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 51fe1a2..59d03a9 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1638,8 +1638,11 @@ sub startup { = $ret->{real_arrival}->epoch - $now->epoch; $ret->{journey_duration} = $ret->{real_arrival}->epoch - $ret->{real_departure}->epoch; - $ret->{journey_completion} = 1 - ( - $ret->{arrival_countdown} / $ret->{journey_duration} ); + $ret->{journey_completion} + = $ret->{journey_duration} + ? 1 + - ( $ret->{arrival_countdown} / $ret->{journey_duration} ) + : 1; if ( $ret->{journey_completion} > 1 ) { $ret->{journey_completion} = 1; } -- cgit v1.2.3