diff options
| author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-23 17:05:25 +0200 | 
|---|---|---|
| committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-23 17:05:25 +0200 | 
| commit | e51b0922c375710985273517f8503a0c216b0c1b (patch) | |
| tree | 73949e03492c52c0b06ec5d93537c630b6b3789a /lib/Travelynx/Model | |
| parent | d8603b9d852104097a65d09cdb0d104ceff6a149 (diff) | |
Manual journey entry: support sched arr/dep timestamps of intermediate stops
Diffstat (limited to 'lib/Travelynx/Model')
| -rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 34 | 
1 files changed, 25 insertions, 9 deletions
| diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index 876786a..d584d99 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -4,16 +4,16 @@ package Travelynx::Model::Journeys;  #  # SPDX-License-Identifier: AGPL-3.0-or-later -use GIS::Distance; -use List::MoreUtils qw(after_incl before_incl); -  use strict;  use warnings;  use 5.020;  use utf8;  use DateTime; +use DateTime::Format::Strptime; +use GIS::Distance;  use JSON; +use List::MoreUtils qw(after_incl before_incl);  my %visibility_itoa = (  	100 => 'public', @@ -183,20 +183,36 @@ sub add {  	}  	if ( $opt{route} ) { +		my $parser = DateTime::Format::Strptime->new( +			pattern   => '%d.%m.%Y %H:%M', +			locale    => 'de_DE', +			time_zone => 'Europe/Berlin' +		);  		my @unknown_stations; +  		for my $station ( @{ $opt{route} } ) { +			my $ts; +			my %station_data; +			if ( $station +				=~ m{ ^ (?<stop> [^@]+? ) \s* [@] \s* (?<timestamp> .+ ) $ }x ) +			{ +				$station = $+{stop}; +				$ts      = $parser->parse_datetime( $+{timestamp} ); +				if ($ts) { +					$station_data{sched_arr} = $ts->epoch; +					$station_data{sched_dep} = $ts->epoch; +				} +			}  			my $station_info = $self->{stations}  			  ->search( $station, backend_id => $opt{backend_id} );  			if ($station_info) { +				$station_data{lat} = $station_info->{lat}; +				$station_data{lon} = $station_info->{lon};  				push(  					@route,  					[ -						$station_info->{name}, -						$station_info->{eva}, -						{ -							lat => $station_info->{lat}, -							lon => $station_info->{lon}, -						} +						$station_info->{name}, $station_info->{eva}, +						\%station_data,  					]  				);  			} | 
