Commit ef58e86c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

db-iris: implement -om

parent 1d739bfb
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -146,7 +146,6 @@ sub display_result {
		);

		my $d = $line->[5];
		my $need_newlines = 0;

		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";
		}
	}

+24 −0
Original line number Diff line number Diff line
@@ -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.