From 6fa6997cb1bb859272ad3f426ab0e0bb94065c7e Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 3 Oct 2024 11:36:05 +0200 Subject: efa-m: add --json option --- lib/Travel/Status/DE/EFA/Departure.pm | 13 ++++++++++++- lib/Travel/Status/DE/EFA/Stop.pm | 10 +++++++++- lib/Travel/Status/DE/EFA/Trip.pm | 6 +++++- 3 files changed, 26 insertions(+), 3 deletions(-) (limited to 'lib/Travel/Status') diff --git a/lib/Travel/Status/DE/EFA/Departure.pm b/lib/Travel/Status/DE/EFA/Departure.pm index 703b29c..3ad68a5 100644 --- a/lib/Travel/Status/DE/EFA/Departure.pm +++ b/lib/Travel/Status/DE/EFA/Departure.pm @@ -246,7 +246,18 @@ sub route_interesting { sub TO_JSON { my ($self) = @_; - return { %{$self} }; + my $ret = { %{$self} }; + + delete $ret->{strp_stopseq}; + delete $ret->{strp_stopseq_s}; + + for my $k (qw(datetime rt_datetime sched_datetime)) { + if ( $ret->{$k} ) { + $ret->{$k} = $ret->{$k}->epoch; + } + } + + return $ret; } 1; diff --git a/lib/Travel/Status/DE/EFA/Stop.pm b/lib/Travel/Status/DE/EFA/Stop.pm index b97cd18..4d7fbe9 100644 --- a/lib/Travel/Status/DE/EFA/Stop.pm +++ b/lib/Travel/Status/DE/EFA/Stop.pm @@ -30,7 +30,15 @@ sub new { sub TO_JSON { my ($self) = @_; - return { %{$self} }; + my $ret = { %{$self} }; + + for my $k (qw(sched_arr rt_arr arr sched_dep rt_dep dep)) { + if ( $ret->{$k} ) { + $ret->{$k} = $ret->{$k}->epoch; + } + } + + return $ret; } 1; diff --git a/lib/Travel/Status/DE/EFA/Trip.pm b/lib/Travel/Status/DE/EFA/Trip.pm index 6c404a1..b1e3437 100644 --- a/lib/Travel/Status/DE/EFA/Trip.pm +++ b/lib/Travel/Status/DE/EFA/Trip.pm @@ -106,7 +106,11 @@ sub route { sub TO_JSON { my ($self) = @_; - return { %{$self} }; + my $ret = { %{$self} }; + + delete $ret->{strptime_obj}; + + return $ret; } 1; -- cgit v1.2.3