diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-10-03 18:22:27 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-10-03 18:22:27 +0200 |
commit | 571f956830a4b7e937490bef7d3643600055ddca (patch) | |
tree | 411bfb21bb59f1abed31a873556ee570b27e63c8 /lib/Travel | |
parent | e872f700fe634dd47a5eb9278c178508b0c10d9e (diff) |
expose route and arrival times
Diffstat (limited to 'lib/Travel')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS.pm | 33 | ||||
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Result.pm | 2 |
2 files changed, 34 insertions, 1 deletions
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 { |