Commit 6467b8b5 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add -r / --relative option

parent d54ae7d7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
git HEAD

    * Add -r, --relative option to use relative times

Travel::Status::DE::VRR 1.04 - Wed Oct 16 2013

    * Add ->key accessor to Travel::Status::DE::VRR::Line
+23 −6
Original line number Diff line number Diff line
@@ -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,15 +139,26 @@ sub show_results {
		}

		if ( $d->is_cancelled ) {
			if ($relative_times) {
				next;
			}
			else {
				$dtime .= ' CANCELED';
			}
		}
		if ( $d->delay ) {
			$dtime .= ' (+' . $d->delay . ')';
		}

		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<platforms> (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<hh:mm>

Show departures starting at I<time> instead of now
Show departures starting at I<time> instead of now.

=item B<-V>, B<--version>