From cdff0a8efeba471abe297b431160af27e3573905 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Mon, 8 Jan 2024 21:20:22 +0100 Subject: bin/hafas: handle partial cancellations --- bin/hafas | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bin/hafas') diff --git a/bin/hafas b/bin/hafas index 3a50bf7..d5f0612 100755 --- a/bin/hafas +++ b/bin/hafas @@ -297,12 +297,16 @@ for my $res ( $hafas->connections ) { } my $negative_transfer; + my $part_cancelled; my $glance = q{}; for my $sec ( $res->sections ) { if ( $sec->type ne 'JNY' ) { next; } + if ( $sec->dep_cancelled or $sec->arr_cancelled ) { + $part_cancelled = 1; + } if ( defined $sec->transfer_duration ) { if ( $sec->transfer_duration->in_units('minutes') >= 0 ) { $glance .= sprintf( @@ -321,12 +325,14 @@ for my $res ( $hafas->connections ) { } } - if ( $cancelled or $negative_transfer ) { + if ( $cancelled or $negative_transfer or $part_cancelled ) { printf( - "--:-- (%02d:%02d) %s %s %s\n", + "%s (%02d:%02d) %s %s %s\n", + $res->dep->strftime('XX.XX. %H:%M'), $res->duration->in_units( 'hours', 'minutes' ), - $res->arr->strftime(' %H:%M'), - display_occupancies( $res->load ), $glance + $res->arr->strftime('%H:%M'), + display_occupancies( $res->load ), + $glance ); } else { -- cgit v1.2.3