Fix division by zero when calculating journey completion
This commit is contained in:
parent
ef77bfcdea
commit
022465d2a7
1 changed files with 5 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue