From e39d7356cfa67fae4c629dd048824125df7114f4 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 5 Jan 2024 01:14:58 +0100 Subject: /z/:train: Add support for date=DD.MM.[YYYY] parameter --- lib/DBInfoscreen/Controller/Stationboard.pm | 17 +++++++++++++++++ lib/DBInfoscreen/Helper/HAFAS.pm | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 23a6ee2..11f499b 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1161,6 +1161,23 @@ sub train_details { $opt{language} = 'en'; } + if ( my $date = $self->param('date') ) { + if ( $date + =~ m{ ^ (? \d{1,2} ) [.] (? \d{1,2} ) [.] (? \d{4})? $ }x + ) + { + $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ); + $opt{datetime}->set( + day => $+{day}, + month => $+{month} + ); + if ( $+{year} ) { + $opt{datetime}->set( year => $+{year} ); + } + say "set $opt{datetime}"; + } + } + $self->stash( hide_opts => 1 ); $self->render_later; diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 1b9226d..525cc45 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -58,7 +58,7 @@ sub get_route_timestamps_p { $hafas_promise //= Travel::Status::DE::HAFAS->new_p( journeyMatch => $opt{train_req} =~ s{^- }{}r, - datetime => ( $opt{train} ? $opt{train}->start : undef ), + datetime => ( $opt{train} ? $opt{train}->start : $opt{datetime} ), language => $opt{language}, cache => $self->{realtime_cache}, promise => 'Mojo::Promise', -- cgit v1.2.3