diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-11-12 09:33:28 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-11-12 09:33:28 +0100 |
commit | a6068c9a4af9a6ddaa9f16204a1d85828663c90b (patch) | |
tree | 85c43b5a4d839b8ded8ebdf5af9c662690a97451 | |
parent | b3915fbeeb0d3b732d76bef878c66b8ff5b0c814 (diff) |
hafas: do not show duration if the journey is impossible
-rwxr-xr-x | bin/hafas | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -274,11 +274,14 @@ if ($json_output) { exit 0; } -for my $res ( @{ $hafas->{results} } ) { +for my $res ( $hafas->connections ) { - #if ($res->is_cancelled) { - # say "# cancelled\n"; - #} + my $cancelled; + for my $msg ( $res->messages ) { + if ( $msg->type eq 'C' and $msg->text =~ m{Fahrt fällt aus} ) { + $cancelled = 1; + } + } my $glance = q{}; for my $sec ( $res->sections ) { @@ -297,11 +300,17 @@ for my $res ( @{ $hafas->{results} } ) { } } - printf( - "%02d:%02d %s %s\n", - $res->duration->in_units( 'hours', 'minutes' ), - display_occupancies( $res->load ), $glance - ); + if ($cancelled) { + printf( "--:-- %s %s\n", display_occupancies( $res->load ), $glance ); + } + else { + printf( + "%02d:%02d %s %s\n", + $res->duration->in_units( 'hours', 'minutes' ), + display_occupancies( $res->load ), $glance + ); + } + for my $msg ( $res->messages ) { show_message($msg); } |