diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-09-03 00:41:52 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-09-03 00:41:52 +0200 |
commit | e30c2f3be1e05b4afa8842f256a6ada7b9abb60e (patch) | |
tree | acd7b6ba7502501a76962249bb5eeab8762f1254 /lib/Travel/Status/DE/HAFAS | |
parent | 272f18d86d79552cd1b99cbab3efb7e996b5dfb1 (diff) |
Journey: Handle missing leading 0 in date strings.
Because of course it is missing, because the date string is treated as a
number by the magical API of the data lake, because why wouldn't it be.
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Journey.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm index d9c1be1..b849cb3 100644 --- a/lib/Travel/Status/DE/HAFAS/Journey.pm +++ b/lib/Travel/Status/DE/HAFAS/Journey.pm @@ -89,7 +89,13 @@ sub new { } } - my $date_ref = ( split( qr{[|]}, $jid ) )[4]; + 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}"; + } my $datetime_ref = DateTime::Format::Strptime->new( pattern => '%d%m%Y', time_zone => 'Europe/Berlin' |