diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-28 18:14:23 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-28 18:14:23 +0100 |
commit | 41714c42ee0fcd48e47b5ad1dc77b0727980061b (patch) | |
tree | 3d920928b3890e5f815d1128b931e545fef3bf4a /lib/Travel/Status/DE | |
parent | 31ef58b4217a60429f77b58a5b2c9c549f40d19e (diff) |
trip details: process delays
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS/Location.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/DBRIS/Location.pm b/lib/Travel/Status/DE/DBRIS/Location.pm index c397b60..0355c95 100644 --- a/lib/Travel/Status/DE/DBRIS/Location.pm +++ b/lib/Travel/Status/DE/DBRIS/Location.pm @@ -10,7 +10,7 @@ our $VERSION = '0.01'; Travel::Status::DE::DBRIS::Location->mk_ro_accessors( qw(eva id lat lon name products type is_cancelled is_additional is_separation display_priority - dep arr platform sched_platform rt_platform + dep arr arr_delay dep_delay delay platform sched_platform rt_platform ) ); @@ -50,6 +50,20 @@ sub new { = $opt{strptime_obj}->parse_datetime( $json->{ezAnkunftsZeitpunkt} ); } + if ( $ref->{sched_dep} and $ref->{rt_dep} ) { + $ref->{dep_delay} + = $ref->{rt_dep}->subtract_datetime( $ref->{sched_dep} ) + ->in_units('minutes'); + } + + if ( $ref->{sched_arr} and $ref->{rt_arr} ) { + $ref->{arr_delay} + = $ref->{rt_arr}->subtract_datetime( $ref->{sched_arr} ) + ->in_units('minutes'); + } + + $ref->{delay} = $ref->{arr_delay} // $ref->{dep_delay}; + for my $message ( @{ $json->{priorisierteMeldungen} // [] } ) { if ( $message->{type} and $message->{type} eq 'HALT_AUSFALL' ) { $ref->{is_cancelled} = 1; |