From 0c91406149c1ed3180bac678d679dc5ccb2140e5 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 26 Dec 2024 13:52:46 +0100 Subject: journey: mark current / upcoming stop in route --- bin/dbris-m | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'bin') 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{}; -- cgit v1.2.3