diff options
Diffstat (limited to 'lib/Travel/Status/DE')
-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 { |