Fix division by zero when calculating journey completion

This commit is contained in:
Daniel Friesel 2019-05-08 07:12:54 +02:00
parent ef77bfcdea
commit 022465d2a7

View file

@ -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;
}