diff options
author | Cassidy Dingenskirchen <admin@15318.de> | 2024-02-21 11:45:43 +0100 |
---|---|---|
committer | Birte Friesel <derf@chaosdorf.de> | 2024-02-21 18:17:58 +0100 |
commit | f17a6b76ff9fafd0183df856150b32b226409731 (patch) | |
tree | b2bb1c09d6b40fdf836baff9d6c4fabc77334ec4 /lib/Travel/Status | |
parent | 285a72f07dc306d2887924ad46882f6dc1fea8cf (diff) |
fix #6
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Journey.pm | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm index c43e2e1..d088d90 100644 --- a/lib/Travel/Status/DE/HAFAS/Journey.pm +++ b/lib/Travel/Status/DE/HAFAS/Journey.pm @@ -89,16 +89,30 @@ sub new { my $datetime_ref; - if ( @{ $journey->{stopL} // [] } or $journey->{stbStop} ) { - my $date_ref = ( split( qr{[|]}, $jid ) )[4]; - if ( length($date_ref) < 7 ) { - warn("HAFAS, not even once -- midnight crossing may be bogus"); - } - if ( length($date_ref) == 7 ) { - $date_ref = "0${date_ref}"; + if ( @{ $journey->{stopL} // [] } or $journey->{stbStop}) { + my ($date_ref, $parse_fmt); + if ($jid =~ /#/) { + # ÖBB Journey ID - technically we ought to use Europe/Vienna tz + # but let's not get into that... + $date_ref = ( split( /#/, $jid ) )[12]; + $parse_fmt = '%d%m%y'; + if ( length($date_ref) < 5 ) { + warn("HAFAS, not even once -- midnight crossing may be bogus -- date_ref $date_ref"); + } elsif ( length($date_ref) == 5 ) { + $date_ref = "0${date_ref}"; + } + } else { + # DB Journey ID + $date_ref = ( split( qr{[|]}, $jid ) )[4]; + $parse_fmt = '%d%m%Y'; + if ( length($date_ref) < 7 ) { + warn("HAFAS, not even once -- midnight crossing may be bogus -- date_ref $date_ref"); + } elsif ( length($date_ref) == 7 ) { + $date_ref = "0${date_ref}"; + } } $datetime_ref = DateTime::Format::Strptime->new( - pattern => '%d%m%Y', + pattern => $parse_fmt, time_zone => 'Europe/Berlin' )->parse_datetime($date_ref); } |