get_connecting_trains: departure delay is relevant for connecting trains

This commit is contained in:
Daniel Friesel 2022-09-28 19:40:31 +02:00
parent 9f06b52a00
commit 6f107754fb
No known key found for this signature in database
GPG key ID: 100D5BFB5166E005

View file

@ -295,14 +295,15 @@ sub get_connecting_trains_p {
$iris_train->[2] = $strp->parse_datetime( $iris_train->[2] = $strp->parse_datetime(
$stop->{arrival} ); $stop->{arrival} );
if ( $iris_train->[2] if ( $iris_train->[2]
and $iris_train->[0]->arrival_delay and $iris_train->[0]->departure_delay
and $stop->{arrival} eq and $stop->{arrival} eq
$stop->{plannedArrival} ) $stop->{plannedArrival} )
{ {
# If the departure is delayed, but the arrival supposedly on time, we assume that this is an API issue and manually compute the expected arrival time. # If the departure is delayed, but the arrival supposedly on time, we assume that this is an API issue and manually compute the expected arrival time.
# This avoids cases where a connection is shown as arriving at its destination before having departed at a previous stop. # This avoids cases where a connection is shown as arriving at its destination before having departed at a previous stop.
$iris_train->[2]->add( minutes => $iris_train->[2]
$iris_train->[0]->arrival_delay ); ->add( minutes => $iris_train->[0]
->departure_delay );
} }
last; last;
} }