summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-06-18 21:35:55 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2025-06-18 21:35:55 +0200
commit6a1bf5e3b132a8ffdd6b419b94808b3bfad0fa87 (patch)
tree5fe179fee266e35ed3befc14d8cf2d242a9856b7
parentb965f9f8c18f3572d12cd5caf1578fe83039a2a5 (diff)
Trip details: The endpoint has a time parameter. Using it is a good idea.
This fixes trip detail requests occasionally returning data for yesterday, and should also fix trip detail requests failing entirely. Note that this breaks compatibility with trip IDs obtained from earlier efa-m versions.
-rwxr-xr-xbin/efa-m7
-rw-r--r--lib/Travel/Status/DE/EFA.pm1
-rw-r--r--lib/Travel/Status/DE/EFA/Departure.pm7
3 files changed, 10 insertions, 5 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 3e84e6a..5f69844 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -99,12 +99,15 @@ if ($use_cache) {
my ( $place, $input, $coord, $stopseq, $stopfinder );
if ( @ARGV == 1 ) {
- if ( $ARGV[0] =~ m{ ^ ([^@]*) @ ([^@]*) [(] ([^)]*) [)] (.*) $ }x ) {
+ if ( $ARGV[0]
+ =~ m{ ^ ([^@]*) @ ([^@]*) [(] ([^T]*) T ([^)]*) [)] (.*) $ }x )
+ {
$stopseq = {
stateless => $1,
stop_id => $2,
date => $3,
- key => $4
+ time => $4,
+ key => $5
};
}
elsif ( $ARGV[0] =~ m{ ^ [?] (?<name> .*) $ }x ) {
diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm
index 146f220..59ae624 100644
--- a/lib/Travel/Status/DE/EFA.pm
+++ b/lib/Travel/Status/DE/EFA.pm
@@ -206,6 +206,7 @@ sub new {
stop => $opt{stopseq}{stop_id},
tripCode => $opt{stopseq}{key},
date => $opt{stopseq}{date},
+ time => $opt{stopseq}{time},
coordOutputFormat => 'WGS84[DD.DDDDD]',
outputFormat => 'rapidJson',
useRealtime => '1',
diff --git a/lib/Travel/Status/DE/EFA/Departure.pm b/lib/Travel/Status/DE/EFA/Departure.pm
index 439a061..f66ed95 100644
--- a/lib/Travel/Status/DE/EFA/Departure.pm
+++ b/lib/Travel/Status/DE/EFA/Departure.pm
@@ -177,10 +177,11 @@ sub id {
return $self->{id} = sprintf( '%s@%d(%s)%d',
$self->stateless =~ s{ }{}gr,
- scalar $self->route_pre
- ? ( $self->route_pre )[0]->id_num
+ scalar $self->route_pre ? ( $self->route_pre )[0]->id_num
: $self->stop_id_num,
- $self->sched_datetime->strftime('%Y%m%d'),
+ ( scalar $self->route_pre and ( $self->route_pre )[0]->sched_dep )
+ ? ( $self->route_pre )[0]->sched_dep->strftime('%Y%m%dT%H:%M')
+ : $self->sched_datetime->strftime('%Y%m%dT%H:%M'),
$self->key );
}