summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-10-08 12:30:14 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2023-10-08 12:30:14 +0200
commit0ea5ed8c4864b7a670a346b03c839d0460abff1e (patch)
tree4a29338ad03f88cedce054b637c8d68835e518ba /lib/Travel/Status/DE/HAFAS
parent585a063f27c0ffe25fc8b71f08d28dcec5478832 (diff)
only run cross-midnight code if affected timestamps are present
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS')
-rw-r--r--lib/Travel/Status/DE/HAFAS/Journey.pm24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm
index f364ceb..5549934 100644
--- a/lib/Travel/Status/DE/HAFAS/Journey.pm
+++ b/lib/Travel/Status/DE/HAFAS/Journey.pm
@@ -89,17 +89,21 @@ sub new {
}
}
- 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;
+
+ 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}";
+ }
+ $datetime_ref = DateTime::Format::Strptime->new(
+ pattern => '%d%m%Y',
+ time_zone => 'Europe/Berlin'
+ )->parse_datetime($date_ref);
}
- my $datetime_ref = DateTime::Format::Strptime->new(
- pattern => '%d%m%Y',
- time_zone => 'Europe/Berlin'
- )->parse_datetime($date_ref);
my $class = $product->{cls};