Loading lib/Travelynx/Controller/Traveling.pm +28 −4 Original line number Diff line number Diff line Loading @@ -2621,6 +2621,11 @@ sub add_intransit_form { locale => 'de_DE', time_zone => 'Europe/Berlin' ); my $time_parser = DateTime::Format::Strptime->new( pattern => '%H:%M', locale => 'de_DE', time_zone => 'Europe/Berlin' ); my %opt; my %trip; Loading Loading @@ -2708,7 +2713,7 @@ sub add_intransit_form { if ( $trip{route} ) { my @unknown_stations; my $prev_epoch; my $prev_ts = $trip{sched_departure}; for my $station ( @{ $trip{route} } ) { my $ts; my %station_data; Loading @@ -2717,11 +2722,30 @@ sub add_intransit_form { ) { $station = $+{stop}; # attempt to parse "07:08" short timestamp first $ts = $time_parser->parse_datetime( $+{timestamp} ); if ( $ts ) { # fill in last stop's (or at the first stop, our departure's) # date to complete the datetime $ts = $ts->set( year => $prev_ts->year, month => $prev_ts->month, day => $prev_ts->day ); # if we go back in time with this, assume we went # over midnight and add a day, e.g. in case of a stop # at 23:00 followed by one at 01:30 if ($ts < $prev_ts) { $ts = $ts->add( days => 1 ); } } else { # do a full datetime parse $ts = $parser->parse_datetime( $+{timestamp} ); if ( $ts and $ts->epoch > $prev_epoch ) { } if ( $ts and $ts >= $prev_ts ) { $station_data{sched_arr} = $ts->epoch; $station_data{sched_dep} = $ts->epoch; $prev_epoch = $ts->epoch; $prev_ts = $ts; } else { $self->render( Loading templates/add_intransit.html.ep +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ <li>Eingabe der Fahrt als „Typ Linie Nummer“ oder „Typ Nummer“, z.B. „ICE 100“, „S 1 31133“ oder „ABR RE11 26720“</li> <li>Wenn Nummer nicht bekannt oder vorhanden: einen beliebigen Integer eintragen, z.B. „S 5X 0“ oder „U 11 0“</li> <li>Zeitangaben im Format YYYY-MM-DDTHH:MM.</li> <li>Zeitangaben im Format YYYY-MM-DDTHH:MM. Bei den Zwischenhalten kann auch nur HH:MM angegeben werden</li> <li>Das ausgewählte Backend bestimmt die verfügbaren Halte für Start, Ziel und Route. Siehe auch <a href="/static/stops.csv">stops.csv</a></li> </ul> </div> Loading Loading @@ -69,7 +69,7 @@ %= text_area 'route', id => 'route', class => 'materialize-textarea' <label for="route">Halte (optional)</label><br/> Eine Station pro Zeile, wahlweise Unterwegshalte oder komplette Route<br/> Format: <i>Name</i> oder <i>Name</i> @ <i>Zeitpunkt</i> (inkl. Datum, siehe oben) Format: <i>Name</i> oder <i>Name</i> @ <i>Zeitpunkt</i> (Format siehe oben, ein ggf. ausgelassenes Datum wird ergänzt) </div> </div> <div class="row"> Loading Loading
lib/Travelynx/Controller/Traveling.pm +28 −4 Original line number Diff line number Diff line Loading @@ -2621,6 +2621,11 @@ sub add_intransit_form { locale => 'de_DE', time_zone => 'Europe/Berlin' ); my $time_parser = DateTime::Format::Strptime->new( pattern => '%H:%M', locale => 'de_DE', time_zone => 'Europe/Berlin' ); my %opt; my %trip; Loading Loading @@ -2708,7 +2713,7 @@ sub add_intransit_form { if ( $trip{route} ) { my @unknown_stations; my $prev_epoch; my $prev_ts = $trip{sched_departure}; for my $station ( @{ $trip{route} } ) { my $ts; my %station_data; Loading @@ -2717,11 +2722,30 @@ sub add_intransit_form { ) { $station = $+{stop}; # attempt to parse "07:08" short timestamp first $ts = $time_parser->parse_datetime( $+{timestamp} ); if ( $ts ) { # fill in last stop's (or at the first stop, our departure's) # date to complete the datetime $ts = $ts->set( year => $prev_ts->year, month => $prev_ts->month, day => $prev_ts->day ); # if we go back in time with this, assume we went # over midnight and add a day, e.g. in case of a stop # at 23:00 followed by one at 01:30 if ($ts < $prev_ts) { $ts = $ts->add( days => 1 ); } } else { # do a full datetime parse $ts = $parser->parse_datetime( $+{timestamp} ); if ( $ts and $ts->epoch > $prev_epoch ) { } if ( $ts and $ts >= $prev_ts ) { $station_data{sched_arr} = $ts->epoch; $station_data{sched_dep} = $ts->epoch; $prev_epoch = $ts->epoch; $prev_ts = $ts; } else { $self->render( Loading
templates/add_intransit.html.ep +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ <li>Eingabe der Fahrt als „Typ Linie Nummer“ oder „Typ Nummer“, z.B. „ICE 100“, „S 1 31133“ oder „ABR RE11 26720“</li> <li>Wenn Nummer nicht bekannt oder vorhanden: einen beliebigen Integer eintragen, z.B. „S 5X 0“ oder „U 11 0“</li> <li>Zeitangaben im Format YYYY-MM-DDTHH:MM.</li> <li>Zeitangaben im Format YYYY-MM-DDTHH:MM. Bei den Zwischenhalten kann auch nur HH:MM angegeben werden</li> <li>Das ausgewählte Backend bestimmt die verfügbaren Halte für Start, Ziel und Route. Siehe auch <a href="/static/stops.csv">stops.csv</a></li> </ul> </div> Loading Loading @@ -69,7 +69,7 @@ %= text_area 'route', id => 'route', class => 'materialize-textarea' <label for="route">Halte (optional)</label><br/> Eine Station pro Zeile, wahlweise Unterwegshalte oder komplette Route<br/> Format: <i>Name</i> oder <i>Name</i> @ <i>Zeitpunkt</i> (inkl. Datum, siehe oben) Format: <i>Name</i> oder <i>Name</i> @ <i>Zeitpunkt</i> (Format siehe oben, ein ggf. ausgelassenes Datum wird ergänzt) </div> </div> <div class="row"> Loading