From 4a8d1a097d75ac06bdab33cc421785b8598b0a84 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 3 Oct 2024 20:21:56 +0200 Subject: Stop: Add arr_delay, dep_delay, delay accessors --- lib/Travel/Status/DE/EFA/Stop.pm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/Travel/Status/DE/EFA') diff --git a/lib/Travel/Status/DE/EFA/Stop.pm b/lib/Travel/Status/DE/EFA/Stop.pm index 73143c5..5dd9e35 100644 --- a/lib/Travel/Status/DE/EFA/Stop.pm +++ b/lib/Travel/Status/DE/EFA/Stop.pm @@ -9,9 +9,9 @@ use parent 'Class::Accessor'; our $VERSION = '3.01'; Travel::Status::DE::EFA::Stop->mk_ro_accessors( - qw(sched_arr rt_arr arr - sched_dep rt_dep dep - occupancy + qw(sched_arr rt_arr arr arr_delay + sched_dep rt_dep dep dep_delay + occupancy delay place name full_name id latlon platform niveau) ); @@ -24,6 +24,20 @@ sub new { $ref->{arr} //= $ref->{rt_arr} // $ref->{sched_arr}; $ref->{dep} //= $ref->{rt_dep} // $ref->{sched_dep}; + if ( $ref->{rt_arr} and $ref->{sched_arr} ) { + $ref->{arr_delay} + = $ref->{rt_arr}->subtract_datetime( $ref->{sched_arr} ) + ->in_units('minutes'); + } + + if ( $ref->{rt_dep} and $ref->{sched_dep} ) { + $ref->{dep_delay} + = $ref->{rt_dep}->subtract_datetime( $ref->{sched_dep} ) + ->in_units('minutes'); + } + + $ref->{delay} = $ref->{dep_delay} // $ref->{arr_delay}; + return bless( $ref, $obj ); } -- cgit v1.2.3