diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-14 22:49:45 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-14 22:49:45 +0100 |
commit | a50cdf13d48e2ba9f040cbd1000accdc3b751cdf (patch) | |
tree | 32895154b151a5b6dc4b19792814958727eb598f /lib/Travel/Status/DE | |
parent | 87637c4f37a798718e75b5b9d7fb08a6fc606349 (diff) |
Journey: Add delay accessor
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS.pm | 2 | ||||
-rw-r--r-- | lib/Travel/Status/DE/DBRIS/Journey.pm | 7 |
2 files changed, 7 insertions, 2 deletions
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; } |