Unverified Commit 25c1467f authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

JourneyAtStop: deal with invalid timestamps during DST transition

parent 08ec73fa
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -386,7 +386,8 @@ if ( $opt{station} ) {

	my @results = map { $_->[1] }
	  sort { $a->[0] <=> $b->[0] }
	  map { [ ( $_->dep // $_->arr )->epoch, $_ ] } $status->results;
	  map  { [ $_->dep->epoch, $_ ] }
	  grep { $_->dep } $status->results;

	for my $result (@results) {
		printf(
+2 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ sub new {
		if ( $conf{modes_of_transit} ) {
			@mots = @{ $conf{modes_of_transit} // [] };
		}

		# arr → /ankuenfte
		$req
		  = 'https://www.bahn.de/web/api/reiseloesung/abfahrten'
		  . '?datum='
+8 −2
Original line number Diff line number Diff line
@@ -50,10 +50,16 @@ sub new {
	bless( $ref, $obj );

	if ( $json->{zeit} ) {
		$ref->{sched_dep} = $strptime->parse_datetime( $json->{zeit} );
		eval { $ref->{sched_dep} = $strptime->parse_datetime( $json->{zeit} ); };
		if ($@) {
			warn("Cannot parse sched_dep $json->{zeit}: $@");
		}
	}
	if ( $json->{ezZeit} ) {
		$ref->{rt_dep} = $strptime->parse_datetime( $json->{ezZeit} );
		eval { $ref->{rt_dep} = $strptime->parse_datetime( $json->{ezZeit} ); };
		if ($@) {
			warn("Cannot parse rt_dep $json->{zeit}: $@");
		}
	}
	$ref->{dep} = $ref->{rt_dep} // $ref->{sched_dep};