summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-12-21 18:45:58 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-12-21 18:45:58 +0100
commit702918a5e19153c1de8af669743eed8bb46f3487 (patch)
treefbcc41f787004f6d46a9e635796aa19d72a3e41e /lib/Travel/Status/DE/HAFAS
parent1737099d4b5629903eaea16e367980dffa80d281 (diff)
Result: Add ->datetime, ->countdown and ->countdown_sec accessors
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS')
-rw-r--r--lib/Travel/Status/DE/HAFAS/Result.pm22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Result.pm b/lib/Travel/Status/DE/HAFAS/Result.pm
index d2d27ab..117e1ea 100644
--- a/lib/Travel/Status/DE/HAFAS/Result.pm
+++ b/lib/Travel/Status/DE/HAFAS/Result.pm
@@ -11,7 +11,7 @@ use parent 'Class::Accessor';
our $VERSION = '2.01';
Travel::Status::DE::HAFAS::Result->mk_ro_accessors(
- qw(date info raw_e_delay raw_delay time train route_end));
+ qw(date datetime info raw_e_delay raw_delay time train route_end));
sub new {
my ( $obj, %conf ) = @_;
@@ -21,6 +21,26 @@ sub new {
return bless( $ref, $obj );
}
+sub countdown {
+ my ($self) = @_;
+
+ $self->{countdown}
+ //= $self->datetime->subtract_datetime( $self->{datetime_now} )
+ ->in_units('minutes');
+
+ return $self->{countdown};
+}
+
+sub countdown_sec {
+ my ($self) = @_;
+
+ $self->{countdown_sec}
+ //= $self->datetime->subtract_datetime( $self->{datetime_now} )
+ ->in_units('seconds');
+
+ return $self->{countdown_sec};
+}
+
sub delay {
my ($self) = @_;