summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-01-13 13:41:54 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-01-13 13:41:54 +0100
commit094d5ccf7e3a7b74d33a7b0db16f37e68d86590c (patch)
tree20edaeb57da8d0802ca808845129e450b22acf92 /lib/Travel
parentef58e86cd740064057186f9a5732f6a62b68bcf1 (diff)
db-iris: -od: only show most recent delay reason. use -oD for all
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index c3dd8aa..58a3a99 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -173,6 +173,25 @@ sub destination {
return $self->route_end;
}
+sub delay_messages {
+ my ($self) = @_;
+
+ my $strp = DateTime::Format::Strptime->new(
+ pattern => '%y%m%d%H%M',
+ time_zone => 'Europe/Berlin',
+ );
+
+ my @keys = sort keys %{ $self->{messages} };
+ my @msgs
+ = uniq( grep { $_->[1] eq 'd' } map { $self->{messages}{$_} } @keys );
+
+ my @ret = map {
+ [ $strp->parse_datetime( $_->[0] ), $self->translate_msg( $_->[2] ) ]
+ } @msgs;
+
+ return @ret;
+}
+
sub messages {
my ($self) = @_;
@@ -181,10 +200,13 @@ sub messages {
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;
+ my @messages = sort keys %{ $self->{messages} };
+ my @ret = map {
+ [
+ $strp->parse_datetime( $self->{messages}->{$_}->[0] ),
+ $self->translate_msg( $self->{messages}->{$_}->[2] )
+ ]
+ } @messages;
return @ret;
}