diff options
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Journey.pm | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm index 9dd5561..952a990 100644 --- a/lib/Travel/Status/DE/HAFAS/Journey.pm +++ b/lib/Travel/Status/DE/HAFAS/Journey.pm @@ -9,6 +9,7 @@ use 5.014; no if $] >= 5.018, warnings => 'experimental::smartmatch'; use parent 'Class::Accessor'; +use DateTime::Format::Strptime; use List::Util qw(any); use Travel::Status::DE::HAFAS::Stop; @@ -88,6 +89,12 @@ sub new { } } + my $date_ref = ( split( qr{[|]}, $jid ) )[4]; + my $datetime_ref = DateTime::Format::Strptime->new( + pattern => '%d%m%Y', + time_zone => 'Europe/Berlin' + )->parse_datetime($date_ref); + my $class = $product->{cls}; my @stops; @@ -114,7 +121,7 @@ sub new { input => $timestr, date => $date, strp_obj => $hafas->{strptime_obj}, - now => $hafas->{now} + ref => $datetime_ref ); } @@ -177,7 +184,6 @@ sub new { } my $ref = { - datetime_now => $hafas->{now}, id => $jid, name => $name, number => $train_no, @@ -232,7 +238,7 @@ sub new { input => $timestr, date => $date, strp_obj => $hafas->{strptime_obj}, - now => $hafas->{now} + ref => $datetime_ref, ); } @@ -282,7 +288,7 @@ sub handle_day_change { if ( length($timestr) == 8 ) { # arrival time includes a day offset - my $offset_date = $opt{now}->clone; + my $offset_date = $opt{ref}->clone; $offset_date->add( days => substr( $timestr, 0, 2, q{} ) ); $offset_date = $offset_date->strftime('%Y%m%d'); $timestr = $opt{strp_obj}->parse_datetime("${offset_date}T${timestr}"); |