Unverified Commit 6b575af0 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Ignore journeys with invalid timestamps during DST change

parent 07e0e2bc
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -863,6 +863,7 @@ sub parse_board {
	my @jnyL = @{ $self->{raw_json}{svcResL}[0]{res}{jnyL} // [] };

	for my $result (@jnyL) {
		eval {
			push(
				@{ $self->{results} },
				Travel::Status::DE::HAFAS::Journey->new(
@@ -873,6 +874,19 @@ sub parse_board {
					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;
}