summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-10-17 09:51:27 +0200
committerDaniel Friesel <derf@finalrewind.org>2022-10-17 09:51:27 +0200
commitef5d75fccec72506f5da2bfa10f2786c9c0492fd (patch)
tree7de8a90e4c8188e788caf691bb0c90b3084130f2
parentb27d67d4894bfb6318efd6b11f35142f55c12b4d (diff)
Journey: TO_JSON: convert DateTime to epoch
-rw-r--r--lib/Travel/Status/DE/HAFAS/Journey.pm18
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 {