diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-10-17 09:51:27 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-10-17 09:51:27 +0200 |
commit | ef5d75fccec72506f5da2bfa10f2786c9c0492fd (patch) | |
tree | 7de8a90e4c8188e788caf691bb0c90b3084130f2 /lib/Travel | |
parent | b27d67d4894bfb6318efd6b11f35142f55c12b4d (diff) |
Journey: TO_JSON: convert DateTime to epoch
Diffstat (limited to 'lib/Travel')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Journey.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm index 8dafb82..0e3d52f 100644 --- a/lib/Travel/Status/DE/HAFAS/Journey.pm +++ b/lib/Travel/Status/DE/HAFAS/Journey.pm @@ -266,7 +266,23 @@ sub route { sub TO_JSON { my ($self) = @_; - return { %{$self} }; + my $ret = { %{$self} }; + + for my $k ( keys %{$ret} ) { + if ( ref( $ret->{$k} ) eq 'DateTime' ) { + $ret->{$k} = $ret->{$k}->epoch; + } + } + + for my $stop ( @{ $ret->{route} } ) { + for my $k ( keys %{$stop} ) { + if ( ref( $stop->{$k} ) eq 'DateTime' ) { + $stop->{$k} = $stop->{$k}->epoch; + } + } + } + + return $ret; } sub type { |