summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-03-31 10:26:33 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-03-31 10:26:33 +0200
commit6b575af0e63f4df5d6dd5e217aa2e7ae3bc114ed (patch)
treedc54ddb99d719f1d901c674e09cedd6644a219b6 /lib/Travel/Status/DE/HAFAS.pm
parent07e0e2bc6721f5587e6fd3867765b238b2568e5f (diff)
Ignore journeys with invalid timestamps during DST change
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS.pm')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm34
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index 48fd19b..7dbb1f6 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -863,16 +863,30 @@ sub parse_board {
my @jnyL = @{ $self->{raw_json}{svcResL}[0]{res}{jnyL} // [] };
for my $result (@jnyL) {
- push(
- @{ $self->{results} },
- Travel::Status::DE::HAFAS::Journey->new(
- common => $self->{raw_json}{svcResL}[0]{res}{common},
- prodL => $prodL,
- locL => \@locL,
- journey => $result,
- hafas => $self,
- )
- );
+ eval {
+ push(
+ @{ $self->{results} },
+ Travel::Status::DE::HAFAS::Journey->new(
+ common => $self->{raw_json}{svcResL}[0]{res}{common},
+ prodL => $prodL,
+ locL => \@locL,
+ journey => $result,
+ hafas => $self,
+ )
+ );
+ };
+ if ($@) {
+ if ( $@ =~ m{Invalid local time for date in time zone} ) {
+
+ # Yes, HAFAS does in fact return invalid times during DST change
+ # (as in, it returns 02:XX:XX timestamps when the time jumps from 02:00:00 to 03:00:00)
+ # It's not clear what exactly is going wrong where and whether a 2:30 or a 3:30 journey is the correct one.
+ # For now, silently discard the affected journeys.
+ }
+ else {
+ warn("Skipping $result->{jid}: $@");
+ }
+ }
}
return $self;
}