diff options
-rwxr-xr-x | bin/dbris | 8 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/DBRIS/Connection.pm | 11 |
2 files changed, 15 insertions, 4 deletions
@@ -219,13 +219,15 @@ for my $connection ( $ris->connections ) { say q{}; printf( - "%s (%02d:%02d) %s %s%s\n\n", - $connection->dep - ? $connection->dep->strftime('%d.%m. %H:%M') + "%s (%02d:%02d) %s %s%s%s\n\n", + $connection->dep ? $connection->dep->strftime('%d.%m. %H:%M') : q{??.??. ??:??}, $connection->duration->in_units( 'hours', 'minutes' ), $connection->arr ? $connection->arr->strftime('%H:%M') : q{??:??}, format_occupancy($connection), + defined $connection->price + ? sprintf( ' %s %s', $connection->price, $connection->price_unit ) + : q{}, $header, ); for my $segment ( $connection->segments ) { diff --git a/lib/Travel/Routing/DE/DBRIS/Connection.pm b/lib/Travel/Routing/DE/DBRIS/Connection.pm index f516729..5c2f6b8 100644 --- a/lib/Travel/Routing/DE/DBRIS/Connection.pm +++ b/lib/Travel/Routing/DE/DBRIS/Connection.pm @@ -3,6 +3,7 @@ package Travel::Routing::DE::DBRIS::Connection; use strict; use warnings; use 5.020; +use utf8; use parent 'Class::Accessor'; @@ -16,7 +17,9 @@ Travel::Routing::DE::DBRIS::Connection->mk_ro_accessors( duration sched_duration rt_duration sched_dep rt_dep dep sched_arr rt_arr arr - occupancy occupancy_first occupancy_second) + occupancy occupancy_first occupancy_second + price price_unit + ) ); sub new { @@ -29,9 +32,15 @@ sub new { my $ref = { changes => $json->{umstiegsAnzahl}, id => $json->{tripId}, + price => $json->{angebotsPreis}{betrag}, + price_unit => $json->{angebotsPreis}{waehrung}, strptime_obj => $strptime, }; + if ( $ref->{price_unit} and $ref->{price_unit} eq 'EUR' ) { + $ref->{price_unit} = '€'; + } + if ( my $d = $json->{verbindungsDauerInSeconds} ) { $ref->{sched_duration} = DateTime::Duration->new( hours => int( $d / 3600 ), |