diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-12-01 20:35:08 +0100 |
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-12-01 20:35:08 +0100 |
| commit | 8036bc9c815edab80db007e8e5e515e3fd1e1e4d (patch) | |
| tree | 0fd685994a6d2cb5b5dde98b0accdc69e32e3df0 | |
| parent | fd4b752e6912147b9e2baba5dc252cc04ce9452c (diff) | |
dbris-m: show train type changes along the route
| -rwxr-xr-x | bin/dbris-m | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/bin/dbris-m b/bin/dbris-m index d4c189b..88804d5 100755 --- a/bin/dbris-m +++ b/bin/dbris-m @@ -414,10 +414,16 @@ elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) { } } - printf( "%s %s am %s\n", + printf( + "%s %s am %s\n", $trip->type, - $trip->line_no // join( q{ / }, $trip->trip_numbers ), - $trip->day->strftime('%d.%m.%Y') ); + $trip->line_no // ( + $trip->trip_numbers + ? join( q{ / }, $trip->trip_numbers ) + : $trip->trip_no + ), + $trip->day->strftime('%d.%m.%Y') + ); if ( $trip->operators ) { printf( "Betrieb: %s\n", join( q{, }, $trip->operators ) ); @@ -429,6 +435,11 @@ elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) { $prev_operator = q{}; } + my $prev_type; + if ( scalar $trip->types > 1 ) { + $prev_type = q{}; + } + my $prev_trip_no; if ( scalar $trip->trip_numbers > 1 ) { $prev_trip_no = q{}; @@ -475,11 +486,19 @@ elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) { $prev_operator = $stop->operator; } - if ( defined $prev_trip_no - and defined $stop->trip_no - and $stop->trip_no ne $prev_trip_no ) + if ( + ( + defined $prev_trip_no + and defined $stop->trip_no + and $stop->trip_no ne $prev_trip_no + ) + or ( defined $prev_type + and defined $stop->trip_type + and $stop->trip_type ne $prev_type ) + ) { - printf( ' (%s %s)', $trip->type, $stop->trip_no ); + printf( ' (%s %s)', $stop->trip_type, $stop->trip_no ); + $prev_type = $stop->trip_type; $prev_trip_no = $stop->trip_no; } print("\n"); |
