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

Connection, Connection/Segment: convert DateTime to epoch and Duration to minutes

Fixes --json
parent 3e4cf94a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -156,6 +156,20 @@ sub TO_JSON {

	my $ret = { %{$self} };

	delete $ret->{strptime_obj};

	for my $k (qw(sched_dep rt_dep dep sched_arr rt_arr arr)) {
		if ( $ret->{$k} ) {
			$ret->{$k} = $ret->{$k}->epoch;
		}
	}

	for my $k (qw(sched_duration rt_duration duration)) {
		if ( $ret->{$k} ) {
			$ret->{$k} = $ret->{$k}->in_units('minutes');
		}
	}

	return $ret;
}

+20 −0
Original line number Diff line number Diff line
@@ -201,4 +201,24 @@ sub transfer_notes {
	return @{ $self->{transfer_notes} // [] };
}

sub TO_JSON {
	my ($self) = @_;

	my $ret = { %{$self} };

	for my $k (qw(sched_dep rt_dep dep sched_arr rt_arr arr)) {
		if ( $ret->{$k} ) {
			$ret->{$k} = $ret->{$k}->epoch;
		}
	}

	for my $k (qw(sched_duration rt_duration duration transfer_duration)) {
		if ( $ret->{$k} ) {
			$ret->{$k} = $ret->{$k}->in_units('minutes');
		}
	}

	return $ret;
}

1;