Skip to content
Commits on Source (2)
...@@ -173,7 +173,7 @@ sub format_footpath { ...@@ -173,7 +173,7 @@ sub format_footpath {
return $str; return $str;
} }
sub format_delay { sub format_delay_incl {
my ( $delay, $len ) = @_; my ( $delay, $len ) = @_;
if ( $delay and $len ) { if ( $delay and $len ) {
return sprintf( "(%+${len}d)", $delay ); return sprintf( "(%+${len}d)", $delay );
...@@ -181,6 +181,14 @@ sub format_delay { ...@@ -181,6 +181,14 @@ sub format_delay {
return q{}; return q{};
} }
sub format_delay_excl {
my ( $delay, $len ) = @_;
if ( $delay and $len ) {
return sprintf( " %+${len}d ", $delay );
}
return q{};
}
sub display_routes { sub display_routes {
my (@routes) = @_; my (@routes) = @_;
...@@ -269,21 +277,24 @@ sub display_connection { ...@@ -269,21 +277,24 @@ sub display_connection {
printf( printf(
"%-5s %-${delay_fmt}s ab %-30s\n", "%-5s %-${delay_fmt}s ab %-30s\n",
$c->departure_time, $c->departure_time,
format_delay( $c->departure_delay, $delay_len ), format_delay_incl( $c->departure_delay, $delay_len ),
$c->departure_stop_and_platform, $c->departure_stop_and_platform,
); );
if ( $opt->{'full-route'} ) { if ( $opt->{'full-route'} ) {
for my $via_stop ( $c->via ) { for my $via_stop ( $c->via ) {
printf( "%-5s %-${delay_fmt}s %-30s %s\n", printf(
$via_stop->[1], q{}, $via_stop->[2], $via_stop->[3] ); "%-5s %-${delay_fmt}s %-30s %s\n",
$via_stop->[1], format_delay_excl( $via_stop->[4], $delay_len ),
$via_stop->[2], $via_stop->[3]
);
} }
} }
printf( printf(
"%-5s %-${delay_fmt}s an %-30s %s\n", "%-5s %-${delay_fmt}s an %-30s %s\n",
$c->arrival_time, $c->arrival_time,
format_delay( $c->arrival_delay, $delay_len ), format_delay_incl( $c->arrival_delay, $delay_len ),
$c->arrival_stop_and_platform, $occupancy $c->arrival_stop_and_platform, $occupancy
); );
......
...@@ -717,8 +717,8 @@ sub parse_xml_part { ...@@ -717,8 +717,8 @@ sub parse_xml_part {
$hash->{arrival_stationmaps} = \@arr_sms; $hash->{arrival_stationmaps} = \@arr_sms;
for my $ve ( $e->findnodes($xp_via) ) { for my $ve ( $e->findnodes($xp_via) ) {
my $e_vdate = ( $ve->findnodes($xp_date) )[-1]; my $e_vdate = ( $ve->findnodes($xp_date) )[0];
my $e_vtime = ( $ve->findnodes($xp_time) )[-1]; my $e_vtime = ( $ve->findnodes($xp_time) )[0];
if ( not( $e_vdate and $e_vtime ) if ( not( $e_vdate and $e_vtime )
or ( $e_vdate->getAttribute('weekday') == -1 ) ) or ( $e_vdate->getAttribute('weekday') == -1 ) )
...@@ -726,8 +726,9 @@ sub parse_xml_part { ...@@ -726,8 +726,9 @@ sub parse_xml_part {
next; next;
} }
my $name = $ve->getAttribute('name'); my $name = $ve->getAttribute('name');
my $platform = $ve->getAttribute('platformName'); my $platform = $ve->getAttribute('platformName');
my $arr_delay = $ve->getAttribute('arrDelay');
if ( $name eq $hash->{departure_stop} if ( $name eq $hash->{departure_stop}
or $name eq $hash->{arrival_stop} ) or $name eq $hash->{arrival_stop} )
...@@ -741,7 +742,8 @@ sub parse_xml_part { ...@@ -741,7 +742,8 @@ sub parse_xml_part {
$self->itddate_str($e_vdate), $self->itddate_str($e_vdate),
$self->itdtime_str($e_vtime), $self->itdtime_str($e_vtime),
$name, $name,
$platform $platform,
$arr_delay,
] ]
); );
} }
......
...@@ -78,7 +78,7 @@ is( $c0->arrival_time, '14:02', 'r0,0: artime' ); ...@@ -78,7 +78,7 @@ is( $c0->arrival_time, '14:02', 'r0,0: artime' );
is( $c0->arrival_stime, '14:02', 'r0,0: astime' ); is( $c0->arrival_stime, '14:02', 'r0,0: astime' );
is_deeply( ($c0->via)[0], is_deeply( ($c0->via)[0],
['27.11.2011', '13:56', 'Essen Florastr.', 'Bstg. 1'], ['27.11.2011', '13:56', 'Essen Florastr.', 'Bstg. 1', undef],
'r0,0: via[0]'); 'r0,0: via[0]');
is( $c1->delay, 3, 'r0,1: delay' ); is( $c1->delay, 3, 'r0,1: delay' );
......