From 6467b8b5e149cce9dff5ee9c221f31af79768677 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 13 Dec 2013 10:18:20 +0100 Subject: add -r / --relative option --- bin/efa-m | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'bin/efa-m') diff --git a/bin/efa-m b/bin/efa-m index 6d542f8..525ea01 100755 --- a/bin/efa-m +++ b/bin/efa-m @@ -13,7 +13,7 @@ use Getopt::Long qw(:config no_ignore_case); use List::Util qw(max); use Travel::Status::DE::VRR; -my ( $date, $time, $input_type, $list_lines ); +my ( $date, $time, $input_type, $list_lines, $relative_times ); my ( @grep_lines, @grep_platforms ); GetOptions( @@ -22,6 +22,7 @@ GetOptions( 'l|line=s@' => \@grep_lines, 'L|linelist' => \$list_lines, 'p|platform=s@' => \@grep_platforms, + 'r|relative' => \$relative_times, 't|time=s' => \$time, 'V|version' => \&show_version, @@ -121,7 +122,8 @@ sub show_results { for my $d ( $status->results ) { my $platform = $d->platform; - my $dtime = $d->time; + my $dtime = ( + $relative_times ? sprintf( '%2d min', $d->countdown ) : $d->time ); if ( $d->platform_db ) { $platform .= ' (DB)'; @@ -137,14 +139,25 @@ sub show_results { } if ( $d->is_cancelled ) { - $dtime .= ' CANCELED'; + if ($relative_times) { + next; + } + else { + $dtime .= ' CANCELED'; + } } if ( $d->delay ) { $dtime .= ' (+' . $d->delay . ')'; } - push( @output, - [ $dtime, $platform, $d->line, $d->destination, $d->info ] ); + if ($relative_times) { + push( @output, + [ $platform, $d->line, $d->destination, $dtime, $d->info ] ); + } + else { + push( @output, + [ $dtime, $platform, $d->line, $d->destination, $d->info ] ); + } } display_result(@output); @@ -204,9 +217,13 @@ repeated) Only show departures at I (comma-separated list, option may be repeated). Note that the C<< Bstg. >> / C<< Gleis >> prefix must be omitted. +=item B<-r>, B<--relative> + +Use relative departure times. + =item B<-t>, B<--time> I -Show departures starting at I