summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/db-iris31
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm24
2 files changed, 42 insertions, 13 deletions
diff --git a/bin/db-iris b/bin/db-iris
index cbda3b6..530af08 100755
--- a/bin/db-iris
+++ b/bin/db-iris
@@ -74,13 +74,13 @@ if ($time) {
for my $efield (@edata_pre) {
given ($efield) {
- when ('d') { $edata{delay} = 1 }
+ when ('d') { $edata{delay} = 1 }
when ('f') { $edata{fullroute} = 1 }
- when ('m') { $edata{messages} = 1 }
- when ('q') { $edata{qos} = 1 }
- when ('r') { $edata{route} = 1 }
- when ('t') { $edata{times} = 1 }
- default { $edata{$efield} = 1 }
+ when ('m') { $edata{messages} = 1 }
+ when ('q') { $edata{qos} = 1 }
+ when ('r') { $edata{route} = 1 }
+ when ('t') { $edata{times} = 1 }
+ default { $edata{$efield} = 1 }
}
}
@@ -145,8 +145,7 @@ sub display_result {
@{$line}[ 0 .. 4 ]
);
- my $d = $line->[5];
- my $need_newlines = 0;
+ my $d = $line->[5];
if ( $edata{times} ) {
if ( not defined $d->delay ) {
@@ -166,13 +165,19 @@ sub display_result {
}
- if ( $edata{fullroute} ) {
- $need_newlines = 1;
- print "\n" . join( "\n", $d->route );
+ if ( $edata{messages} ) {
+ for my $message ( reverse $d->messages ) {
+
+ # leading spaces to align with regular output
+ printf( " %s %s\n",
+ $message->[0]->strftime('%d.%m. %H:%M'),
+ $message->[1] );
+ }
+ print "\n";
}
- if ($need_newlines) {
- print "\n\n";
+ if ( $edata{fullroute} ) {
+ print "\n" . join( "\n", $d->route ) . "\n\n";
}
}
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index 4eb3096..c3dd8aa 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -173,6 +173,22 @@ sub destination {
return $self->route_end;
}
+sub messages {
+ my ($self) = @_;
+
+ my $strp = DateTime::Format::Strptime->new(
+ pattern => '%y%m%d%H%M',
+ time_zone => 'Europe/Berlin',
+ );
+
+ my @messages = sort keys %{ $self->{messages } };
+ my @ret = map { [ $strp->parse_datetime($self->{messages}->{$_}->[0]),
+ $self->translate_msg($self->{messages}->{$_}->[2]) ] }
+ @messages;
+
+ return @ret;
+}
+
sub info {
my ($self) = @_;
@@ -460,6 +476,14 @@ usually do not have this field set, even if they have a common line number
Example: For the line C<< S 1 >>, line_no will return C<< 1 >>.
+=item $result->messages
+
+Get all qos and delay messages ever entered for this train. Returns a list
+of [datetime, string] listrefs. The datetime part is a DateTime(3pm) object
+corresponding to the point in time when the message was entered, the string
+is the message. Note that neither duplicates nor superseded messages are
+filtered from this list.
+
=item $result->origin
Alias for route_start.