From 571f956830a4b7e937490bef7d3643600055ddca Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 3 Oct 2022 18:22:27 +0200 Subject: expose route and arrival times --- lib/Travel/Status/DE/HAFAS.pm | 33 +++++++++++++++++++++++++++++++++ lib/Travel/Status/DE/HAFAS/Result.pm | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm index 2a2b3f4..a1660c8 100644 --- a/lib/Travel/Status/DE/HAFAS.pm +++ b/lib/Travel/Status/DE/HAFAS.pm @@ -495,6 +495,38 @@ sub parse_mgate { } } + my @stops; + for my $stop ( @{ $result->{stopL} // [] } ) { + my $loc = $locL[ $stop->{locX} ]; + my $arr = $stop->{aTimeS}; + my $arr_dt; + if ($arr) { + if ( length($arr) == 8 ) { + + # arrival time includes a day offset + my $offset_date = $self->{now}->clone; + $offset_date->add( days => substr( $arr, 0, 2, q{} ) ); + $offset_date = $offset_date->strftime('%Y%m%d'); + $arr_dt = $self->{strptime_obj} + ->parse_datetime("${offset_date}T${arr}"); + } + else { + $arr_dt + = $self->{strptime_obj}->parse_datetime("${date}T${arr}"); + } + } + push( + @stops, + { + name => $loc->{name}, + eva => $loc->{extId} + 0, + arrival => $arr_dt, + } + ); + } + + shift @stops; + push( @{ $self->{results} }, Travel::Status::DE::HAFAS::Result->new( @@ -510,6 +542,7 @@ sub parse_mgate { platform => $platform, new_platform => $new_platform, messages => \@messages, + route => \@stops, ) ); } diff --git a/lib/Travel/Status/DE/HAFAS/Result.pm b/lib/Travel/Status/DE/HAFAS/Result.pm index 1fc13ce..b217473 100644 --- a/lib/Travel/Status/DE/HAFAS/Result.pm +++ b/lib/Travel/Status/DE/HAFAS/Result.pm @@ -12,7 +12,7 @@ our $VERSION = '3.01'; Travel::Status::DE::HAFAS::Result->mk_ro_accessors( qw(sched_date date sched_datetime datetime info is_cancelled operator delay - sched_time time train route_end) + sched_time time train route route_end) ); sub new { -- cgit v1.2.3