diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-10-03 20:21:56 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-10-03 20:21:56 +0200 |
commit | 4a8d1a097d75ac06bdab33cc421785b8598b0a84 (patch) | |
tree | 4aefb85f6d2ade60cef9e02e54f25e50a7d64b04 /lib/Travel/Status/DE/EFA/Stop.pm | |
parent | 80b348157c2c689795bdcd479478283920cf2612 (diff) |
Stop: Add arr_delay, dep_delay, delay accessors
Diffstat (limited to 'lib/Travel/Status/DE/EFA/Stop.pm')
-rw-r--r-- | lib/Travel/Status/DE/EFA/Stop.pm | 20 |
1 files changed, 17 insertions, 3 deletions
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 ); } |