Unverified Commit 4a8d1a09 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Stop: Add arr_delay, dep_delay, delay accessors

parent 80b34815
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -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 );
}