diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/DBInfoscreen/Controller/Map.pm | 27 | ||||
| -rw-r--r-- | lib/DBInfoscreen/Helper/HAFAS.pm | 12 | 
2 files changed, 16 insertions, 23 deletions
| diff --git a/lib/DBInfoscreen/Controller/Map.pm b/lib/DBInfoscreen/Controller/Map.pm index 8a84e16..92f3644 100644 --- a/lib/DBInfoscreen/Controller/Map.pm +++ b/lib/DBInfoscreen/Controller/Map.pm @@ -868,20 +868,9 @@ sub search {  	my $t1_data;  	my $t2_data; -	my $now       = DateTime->now( time_zone => 'Europe/Berlin' ); -	my $date_yy   = $now->strftime('%d.%m.%y'); -	my $date_yyyy = $now->strftime('%d.%m.%Y'); - -	# Doesn't seem to matter -- so far, HAFAS is happy as long as the date part -	# starts with a number. HAFAS-internal tripIDs use this format (withouth -	# leading zero for day of month < 10) though, so let's stick with it. -	my $date_map = $now->strftime('%d%m%Y'); -  	if ( $t1 and $t1 =~ m{^\S+\s+\d+$} ) {  		$t1_data = $self->hafas->trainsearch( -			train_no  => $t1, -			date_yy   => $date_yy, -			date_yyyy => $date_yyyy +			train_no => $t1,  		);  	}  	else { @@ -931,21 +920,13 @@ sub search {  	}  	if ( $t1 and not $t2 ) { -		$self->redirect_to( -			sprintf( -				"/map/1|%d|%d|%d|%s/0", -				$t1_data->{id},   $t1_data->{cycle}, -				$t1_data->{pool}, $date_map -			) -		); +		$self->redirect_to( sprintf( "/map/%s/0", $t1_data->{trip_id}, ) );  	}  	elsif ( $t1 and $t2 ) {  		$self->redirect_to(  			sprintf( -				"/intersection/1|%d|%d|%d|%s,0;1|%d|%d|%d|%s,0", -				$t1_data->{id},   $t1_data->{cycle}, $t1_data->{pool}, -				$date_map,        $t2_data->{id},    $t2_data->{cycle}, -				$t2_data->{pool}, $date_map +				"/intersection/%s,0;%s,0", +				$t1_data->{trip_id}, $t2_data->{trip_id},  			)  		);  	} diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 2eda72f..2eb156c 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -198,6 +198,18 @@ sub trainsearch {  		}  	} +	if ($result) { + +		# The trip_id's date part doesn't seem to matter -- so far, HAFAS is +		# happy as long as the date part starts with a number. HAFAS-internal +		# tripIDs use this format (withouth leading zero for day of month < 10) +		# though, so let's stick with it. +		my $date_map = $opt{date_yyyy}; +		$date_map =~ tr{.}{}d; +		$result->{trip_id} = sprintf( '1|%d|%d|%d|%s', +			$result->{id}, $result->{cycle}, $result->{pool}, $date_map ); +	} +  	return $result;  } | 
