diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-26 13:52:46 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-26 13:52:46 +0100 |
commit | 0c91406149c1ed3180bac678d679dc5ccb2140e5 (patch) | |
tree | 24d81e27fb0c42592282dc5d7ea467d8d02694b0 /bin/dbris-m | |
parent | 611e5af908c48b2134c29b36dbd59b9e0940748d (diff) |
journey: mark current / upcoming stop in route
Diffstat (limited to 'bin/dbris-m')
-rwxr-xr-x | bin/dbris-m | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/dbris-m b/bin/dbris-m index 631875e..2049f2d 100755 --- a/bin/dbris-m +++ b/bin/dbris-m @@ -197,10 +197,27 @@ elsif ( $opt{journey} ) { my $max_name = max map { length( $_->name ) } $trip->route; my $max_platform = max map { length( $_->platform // q{} ) } $trip->route; + my $mark_stop = 0; + my $now = DateTime->now( time_zone => 'Europe/Berlin' ); + for my $i ( reverse 1 .. ( scalar $trip->route // 0 ) ) { + my $stop = ( $trip->route )[ $i - 1 ]; + if ( + not $stop->is_cancelled + and ( $stop->dep and $now <= $stop->dep + or $stop->arr and $now <= $stop->arr ) + ) + { + $mark_stop = $stop; + } + } + say $trip->train; say q{}; for my $stop ( $trip->route ) { + if ( $stop == $mark_stop ) { + print($output_bold); + } if ( $stop->is_cancelled ) { print(' --:-- '); } @@ -219,8 +236,11 @@ elsif ( $opt{journey} ) { else { print(' '); } - printf( " %${max_name}s %${max_platform}s\n", + printf( " %-${max_name}s %${max_platform}s\n", $stop->name, $stop->platform // q{} ); + if ( $stop == $mark_stop ) { + print($output_reset); + } } if ( $trip->messages ) { say q{}; |