Unverified Commit ef5d75fc authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Journey: TO_JSON: convert DateTime to epoch

parent b27d67d4
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -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 {