Unverified Commit 0aba524a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

efa: show a summary of each connection before the details

parent 10ead630
Loading
Loading
Loading
Loading
+24 −12
Changes for bin/efa: 24 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -198,18 +198,7 @@ sub display_routes {

		my $route = $routes[$i];

		if ( $opt->{'extended-info'} ) {
			print '# ' . $route->duration;
			if ( $route->ticket_type ) {
				printf( ", Preisstufe %s (%s€ / %s€)\n\n",
					$route->ticket_type, $route->fare_adult,
					$route->fare_child, );
			}
			else {
				print "\n\n";
			}
		}

		my $glance    = q{};
		my $delay_len = 0;
		for my $c ( $route->parts ) {
			if ( $c->departure_delay ) {
@@ -219,6 +208,29 @@ sub display_routes {
			if ( $c->arrival_delay ) {
				$delay_len = max( $delay_len, length( $c->arrival_delay ) + 1 );
			}
			if ( $c->train_line and $c->train_line =~ m{ } ) {
				$glance .= '  ' . $c->train_line =~ s{ ^ \S+ \s+ }{}rx;
			}
			else {
				$glance .= '  ' . $c->train_line // $c->train_product;
			}
		}

		printf(
			"%s %s  (%s)  %s    %s\n\n",
			( $route->parts )[0]->departure_date,
			( $route->parts )[0]->departure_time,
			$route->duration,
			( $route->parts )[-1]->arrival_time,
			$glance,
		);

		if ( $opt->{'extended-info'} ) {
			if ( $route->ticket_type ) {
				printf( ", Preisstufe %s (%s€ / %s€)\n\n",
					$route->ticket_type, $route->fare_adult,
					$route->fare_child, );
			}
		}

		for my $c ( $route->parts ) {
+4 −3
Changes for lib/Travel/Routing/DE/EFA.pm: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -62,7 +62,10 @@ sub set_time {
		);
	}

	if ( $time !~ / ^ [0-2]? \d : [0-5]? \d $ /x ) {
	if ( $time =~ m{ ^ ([0-2]? \d) :? ([0-5] \d) $ }x ) {
		@{ $self->{post} }{ 'itdTimeHour', 'itdTimeMinute' } = ( $1, $2 );
	}
	else {
		Travel::Routing::DE::EFA::Exception::Setup->throw(
			option => 'time',
			have   => $time,
@@ -70,8 +73,6 @@ sub set_time {
		);
	}

	@{ $self->{post} }{ 'itdTimeHour', 'itdTimeMinute' } = split( /:/, $time );

	return;
}