diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-24 19:53:18 +0200 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-24 19:53:18 +0200 |
commit | 9e6728a3e14fbe48b7e7aa1d7c0ae2d4e79f0ece (patch) | |
tree | 397250252d80b5bfe56339f2c8149a10c36cf2b3 | |
parent | f9b69b597213430fb7bc22d22ea735b0cd8e81b8 (diff) |
Journeys->add: a little bit of sanity checking for route timestamps
-rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index eef4309..30f3179 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -189,6 +189,7 @@ sub add { time_zone => 'Europe/Berlin' ); my @unknown_stations; + my $prev_epoch = 0; for my $station ( @{ $opt{route} } ) { my $ts; @@ -199,8 +200,15 @@ sub add { $station = $+{stop}; $ts = $parser->parse_datetime( $+{timestamp} ); if ($ts) { - $station_data{sched_arr} = $ts->epoch; - $station_data{sched_dep} = $ts->epoch; + my $epoch = $ts->epoch; + if ( $epoch <= $prev_epoch ) { + return ( undef, +'Zeitstempel der Unterwegshalte müssen streng monoton steigend sein (keine Zeitreisen und keine Portale)' + ); + } + $station_data{sched_arr} = $epoch; + $station_data{sched_dep} = $epoch; + $prev_epoch = $epoch; } } my $station_info = $self->{stations} |