diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-05-07 22:12:33 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-05-07 22:12:33 +0200 |
commit | dfd50dae2fd80ca7d1f9bf6892067fba93571ed2 (patch) | |
tree | c2487dc7817abf85b55931cda9078cd1ba57b3f6 /lib/Travel/Status/DE/HAFAS | |
parent | 8745b66e4956afaf73e39b5966c7733b0e2944d0 (diff) |
Result: Report real time by default
Scheduled time is now available via sched_* accessors
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Result.pm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Result.pm b/lib/Travel/Status/DE/HAFAS/Result.pm index 2950736..e5c81c0 100644 --- a/lib/Travel/Status/DE/HAFAS/Result.pm +++ b/lib/Travel/Status/DE/HAFAS/Result.pm @@ -11,14 +11,29 @@ use parent 'Class::Accessor'; our $VERSION = '2.05'; Travel::Status::DE::HAFAS::Result->mk_ro_accessors( - qw(date datetime info raw_e_delay raw_delay time train route_end)); + qw(sched_date date sched_datetime datetime info raw_e_delay raw_delay + sched_time time train route_end) +); sub new { my ( $obj, %conf ) = @_; my $ref = \%conf; + bless( $ref, $obj ); - return bless( $ref, $obj ); + if ( my $delay = $ref->delay ) { + $ref->{datetime} + = $ref->{sched_datetime}->clone->add( minutes => $delay ); + $ref->{date} = $ref->{datetime}->strftime('%d.%m.%Y'); + $ref->{time} = $ref->{datetime}->strftime('%H:%M'); + } + else { + $ref->{datetime} = $ref->{sched_datetime}; + $ref->{date} = $ref->{sched_date}; + $ref->{time} = $ref->{sched_time}; + } + + return $ref; } sub countdown { |