Skip to content

Commit

Permalink
parse and expose arrival delay
Browse files Browse the repository at this point in the history
  • Loading branch information
derf committed Nov 7, 2023
1 parent ddec189 commit 6c19174
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/Travel/Routing/DE/EFA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ sub parse_xml_part {
$e_astime //= $e_atime;

my $delay = $e_delay ? $e_delay->getAttribute('delayMinutes') : 0;
my $delay_arr
= $e_delay ? $e_delay->getAttribute('delayMinutesArr') : 0;

my ( @dep_rms, @dep_sms, @arr_rms, @arr_sms );

Expand All @@ -673,8 +675,8 @@ sub parse_xml_part {
}

my $hash = {
delay => $delay,
departure_date => $self->itddate_str($e_ddate),
departure_delay => $delay,
departure_time => $self->itdtime_str($e_dtime),
departure_sdate => $self->itddate_str($e_dsdate),
departure_stime => $self->itdtime_str($e_dstime),
Expand All @@ -685,6 +687,7 @@ sub parse_xml_part {
train_product => $e_mot->getAttribute('productName'),
train_destination => $e_mot->getAttribute('destination'),
arrival_date => $self->itddate_str($e_adate),
arrival_delay => $delay_arr,
arrival_time => $self->itdtime_str($e_atime),
arrival_sdate => $self->itddate_str($e_asdate),
arrival_stime => $self->itdtime_str($e_astime),
Expand Down
19 changes: 15 additions & 4 deletions lib/Travel/Routing/DE/EFA/Route/Part.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ my %occupancy = (

Travel::Routing::DE::EFA::Route::Part->mk_ro_accessors(
qw(arrival_platform arrival_stop
arrival_date arrival_time arrival_sdate arrival_stime delay
departure_platform
arrival_date arrival_time arrival_sdate arrival_stime arrival_delay
delay
departure_platform departure_delay
departure_stop departure_date departure_time departure_sdate
departure_stime
footpath_duration footpath_type
occupancy
train_destination train_line train_product
)
)
);

sub new {
Expand All @@ -38,6 +39,8 @@ sub new {
delete $ref->{occupancy};
}

$ref->{delay} = $ref->{departure_delay};

return bless( $ref, $obj );
}

Expand Down Expand Up @@ -188,6 +191,10 @@ included in the calculation, "Scheduled" means it isn't.
=over
=item $part->arrival_delay
arrival delay in minutes, 0 if unknown
=item $part->arrival_stop
arrival stop (city name plus station name)
Expand Down Expand Up @@ -237,7 +244,11 @@ Returns a list of Travel::Routing::DE::EFA::Route::Message(3pm) objects.
=item $part->delay
delay in minutes, 0 if unknown
alias for departure_delay
=item $part->departure_delay
departure delay in minutes, 0 if unknown
=item $part->departure_stop
Expand Down

0 comments on commit 6c19174

Please sign in to comment.