summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Travel/Routing/DE/DBRIS/Connection.pm14
-rw-r--r--lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm20
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/Travel/Routing/DE/DBRIS/Connection.pm b/lib/Travel/Routing/DE/DBRIS/Connection.pm
index 82373a6..b090e01 100644
--- a/lib/Travel/Routing/DE/DBRIS/Connection.pm
+++ b/lib/Travel/Routing/DE/DBRIS/Connection.pm
@@ -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;
}
diff --git a/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm b/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm
index 11e0bf5..896b506 100644
--- a/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm
+++ b/lib/Travel/Routing/DE/DBRIS/Connection/Segment.pm
@@ -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;