From a50cdf13d48e2ba9f040cbd1000accdc3b751cdf Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 14 Dec 2024 22:49:45 +0100 Subject: Journey: Add delay accessor --- lib/Travel/Status/DE/DBRIS.pm | 2 +- lib/Travel/Status/DE/DBRIS/Journey.pm | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Travel/Status/DE/DBRIS.pm b/lib/Travel/Status/DE/DBRIS.pm index a2bf311..d9dc0d5 100644 --- a/lib/Travel/Status/DE/DBRIS.pm +++ b/lib/Travel/Status/DE/DBRIS.pm @@ -50,7 +50,7 @@ sub new { if ( my $eva = $conf{station} ) { $req - = "https://www.bahnhof.de/api/boards/departures?evaNumbers=${eva}&duration=60&stationCategory=1&locale=de&sortBy=TIME_SCHEDULE"; + = "https://www.bahnhof.de/api/boards/departures?evaNumbers=${eva}&duration=60&stationCategory=1&locale=de&sortBy=TIME"; } elsif ( my $gs = $conf{geoSearch} ) { my $lat = $gs->{latitude}; diff --git a/lib/Travel/Status/DE/DBRIS/Journey.pm b/lib/Travel/Status/DE/DBRIS/Journey.pm index df7eada..30026ca 100644 --- a/lib/Travel/Status/DE/DBRIS/Journey.pm +++ b/lib/Travel/Status/DE/DBRIS/Journey.pm @@ -9,7 +9,7 @@ use parent 'Class::Accessor'; our $VERSION = '0.01'; Travel::Status::DE::DBRIS::Journey->mk_ro_accessors( - qw(type dep sched_dep rt_dep is_cancelled line stop_name stop_eva id admin_id journey_id sched_platform platform dest_name dest_eva route) + qw(type dep sched_dep rt_dep delay is_cancelled line stop_name stop_eva id admin_id journey_id sched_platform platform dest_name dest_eva route) ); sub new { @@ -40,6 +40,11 @@ sub new { } $ref->{dep} = $ref->{rt_dep} // $ref->{schd_dep}; + if ( $ref->{sched_dep} and $ref->{rt_dep} ) { + $ref->{delay} = $ref->{rt_dep}->subtract_datetime( $ref->{sched_dep} ) + ->in_units('minutes'); + } + return $ref; } -- cgit v1.2.3