From 44cdac57eed0f02c8801ed85d08be4e7daead991 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 8 Sep 2020 17:48:09 +0200 Subject: move tripid generation to trainsearch helper --- lib/DBInfoscreen/Helper/HAFAS.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/DBInfoscreen/Helper/HAFAS.pm') 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; } -- cgit v1.2.3