summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/EFA
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-10-08 21:08:59 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-10-08 21:08:59 +0200
commitdb7869656bff9430f21059a6fbb6ad956e038ddc (patch)
tree40f5901743efcd97fbf0d6568a7a3320dfdedffc /lib/Travel/Status/DE/EFA
parent53a4766b0d3e78bd73f0be5567d5383eba6cbd3f (diff)
Stop: Calculate rt_{arr,dep} if needed
Diffstat (limited to 'lib/Travel/Status/DE/EFA')
-rw-r--r--lib/Travel/Status/DE/EFA/Stop.pm20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/EFA/Stop.pm b/lib/Travel/Status/DE/EFA/Stop.pm
index e760713..af55ee3 100644
--- a/lib/Travel/Status/DE/EFA/Stop.pm
+++ b/lib/Travel/Status/DE/EFA/Stop.pm
@@ -21,16 +21,32 @@ sub new {
my $ref = \%conf;
+ if ( $ref->{sched_arr} and $ref->{arr_delay} and not $ref->{rt_arr} ) {
+ $ref->{rt_arr}
+ = $ref->{sched_arr}->clone->add( minutes => $ref->{arr_delay} );
+ }
+
+ if ( $ref->{sched_dep} and $ref->{dep_delay} and not $ref->{rt_dep} ) {
+ $ref->{rt_dep}
+ = $ref->{sched_dep}->clone->add( minutes => $ref->{dep_delay} );
+ }
+
$ref->{arr} //= $ref->{rt_arr} // $ref->{sched_arr};
$ref->{dep} //= $ref->{rt_dep} // $ref->{sched_dep};
- if ( $ref->{rt_arr} and $ref->{sched_arr} ) {
+ if ( $ref->{rt_arr}
+ and $ref->{sched_arr}
+ and not defined $ref->{arr_delay} )
+ {
$ref->{arr_delay}
= $ref->{rt_arr}->subtract_datetime( $ref->{sched_arr} )
->in_units('minutes');
}
- if ( $ref->{rt_dep} and $ref->{sched_dep} ) {
+ if ( $ref->{rt_dep}
+ and $ref->{sched_dep}
+ and not defined $ref->{dep_delay} )
+ {
$ref->{dep_delay}
= $ref->{rt_dep}->subtract_datetime( $ref->{sched_dep} )
->in_units('minutes');