From 8ab29ec6ac3be4d96aec1ebc55ad4d77a105d05e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 24 Sep 2015 20:29:58 +0200 Subject: turns out delayReason holds more data than anticipated --- lib/Travel/Status/DE/HAFAS.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm index 12bc08f..0e588fc 100644 --- a/lib/Travel/Status/DE/HAFAS.pm +++ b/lib/Travel/Status/DE/HAFAS.pm @@ -253,9 +253,9 @@ sub similar_stops { if ( $service and exists $hafas_instance{$service}{stopfinder} ) { my $sf = Travel::Status::DE::HAFAS::StopFinder->new( - url => $hafas_instance{$service}{stopfinder}, - input => $self->{station}, - ua => $self->{ua}, + url => $hafas_instance{$service}{stopfinder}, + input => $self->{station}, + ua => $self->{ua}, developer_mode => $self->{developer_mode}, ); if ( my $err = $sf->errstr ) { @@ -307,10 +307,16 @@ sub results { substr( $date, 6, 0, '20' ); - # delayReason=" " means no delay reason - if ( $info eq q{ } ) { + # TODO the first charactor of delayReason is special: + # " " -> no additional data, rest (if any) is delay reason + # else -> first word is not a delay reason but additional data, + # for instance "Zusatzfahrt/Ersatzfahrt" for a replacement train + if ( $info and $info eq q{ } ) { $info = undef; } + elsif ( substr( $info, 0, 1 ) eq q{ } ) { + substr( $info, 0, 1, q{} ); + } $train =~ s{#.*$}{}; -- cgit v1.2.3