summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-06-15 18:56:13 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2025-06-15 18:56:13 +0200
commit22d7855641ece6dfda7eb5689df88802ee1ce8ff (patch)
tree668f554a8ead4d128fe83b1194ab0322d679158c
parentef9542106adb6b8ea6cc40f9a98c808b305e6a28 (diff)
Stop: Add is_cancelled accessor
-rwxr-xr-xbin/efa-m20
-rw-r--r--lib/Travel/Status/DE/EFA/Stop.pm2
-rw-r--r--lib/Travel/Status/DE/EFA/Trip.pm17
3 files changed, 27 insertions, 12 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 1890db9..3367a2f 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -233,7 +233,13 @@ sub format_route {
if ( $stop->delay ) {
$delay = sprintf( '(%+3d)', $stop->delay );
}
- if ( defined $stop->arr and defined $stop->dep ) {
+ if ( $stop->is_cancelled ) {
+ $output .= sprintf(
+ " --:-- %s %s %35s %s\n",
+ $delay, $occupancy, $stop->full_name, $stop->platform // q{},
+ );
+ }
+ elsif ( defined $stop->arr and defined $stop->dep ) {
if ( $stop->arr->epoch == $stop->dep->epoch ) {
$output .= sprintf(
" %5s %s %s %35s %s\n",
@@ -355,6 +361,10 @@ sub show_stopseq {
$delay_len = length( sprintf( '(%+d)', $max_delay ) ) + 1;
}
+ if ( first { $_->is_cancelled } $trip->route and $delay_len < 3 ) {
+ $delay_len = 3;
+ }
+
for my $stop ( $trip->route ) {
printf(
"%s → %s%${delay_len}s %s (%s) %s\n",
@@ -362,8 +372,12 @@ sub show_stopseq {
: q{ },
$stop->dep ? $stop->dep->strftime('%H:%M')
: q{ },
- $stop->delay ? sprintf( " (%+${inner_delay_len}d)", $stop->delay )
- : q{},
+ $stop->is_cancelled ? 'XX'
+ : (
+ $stop->delay
+ ? sprintf( " (%+${inner_delay_len}d)", $stop->delay )
+ : q{}
+ ),
$stop->full_name,
$stop->niveau,
$stop->platform
diff --git a/lib/Travel/Status/DE/EFA/Stop.pm b/lib/Travel/Status/DE/EFA/Stop.pm
index 2860ff5..8cd7186 100644
--- a/lib/Travel/Status/DE/EFA/Stop.pm
+++ b/lib/Travel/Status/DE/EFA/Stop.pm
@@ -11,7 +11,7 @@ our $VERSION = '3.09';
Travel::Status::DE::EFA::Stop->mk_ro_accessors(
qw(sched_arr rt_arr arr arr_delay
sched_dep rt_dep dep dep_delay
- occupancy delay distance_m
+ occupancy delay distance_m is_cancelled
place name full_name id_num id_code latlon
platform niveau)
);
diff --git a/lib/Travel/Status/DE/EFA/Trip.pm b/lib/Travel/Status/DE/EFA/Trip.pm
index 848c630..1e67a07 100644
--- a/lib/Travel/Status/DE/EFA/Trip.pm
+++ b/lib/Travel/Status/DE/EFA/Trip.pm
@@ -152,14 +152,15 @@ sub route {
sched_dep => $self->parse_dt( $stop->{departureTimePlanned} ),
rt_arr => $self->parse_dt( $stop->{arrivalTimeEstimated} ),
rt_dep => $self->parse_dt( $stop->{departureTimeEstimated} ),
- latlon => $stop->{coord},
- full_name => $name_full,
- name => $name,
- place => $place,
- niveau => $stop->{niveau},
- platform => $platform,
- id_code => $id_code,
- id_num => $id_num,
+ is_cancelled => $stop->{isCancelled},
+ latlon => $stop->{coord},
+ full_name => $name_full,
+ name => $name,
+ place => $place,
+ niveau => $stop->{niveau},
+ platform => $platform,
+ id_code => $id_code,
+ id_num => $id_num,
)
);
}