Loading Build.PL +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ Module::Build->new( 'perl' => '5.10.1', 'Carp' => 0, 'Class::Accessor' => '0.16', 'DateTime' => 0, 'DateTime::Format::Strptime' => 0, 'Getopt::Long' => 0, 'JSON' => 0, 'List::MoreUtils' => 0, Loading Changelog +5 −0 Original line number Diff line number Diff line git HEAD * New dependencies: DateTime and DateTime::Format::Strptime * Result: New accessors ->datetime, ->countdown and ->countdown_sec Travel::Status::DE::DeutscheBahn 2.01 - Sat Oct 10 2015 * Result: Fix ->type accessor (was not working for all backends) Loading README +2 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ Dependencies * perl version 5.10.1 or newer * Class::Accessor * DateTime * DateTime::Format::Strptime * JSON * List::MoreUtils * LWP::UserAgent (usually shipped by libwww-perl) Loading lib/Travel/Status/DE/HAFAS.pm +14 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ use utf8; no if $] >= 5.018, warnings => 'experimental::smartmatch'; use Carp qw(confess); use DateTime; use DateTime::Format::Strptime; use LWP::UserAgent; use POSIX qw(strftime); use Travel::Status::DE::HAFAS::Result; Loading Loading @@ -291,6 +293,14 @@ sub results { $self->{results} = []; $self->{datetime_now} //= DateTime->now( time_zone => 'Europe/Berlin', ); $self->{strptime_obj} //= DateTime::Format::Strptime->new( pattern => '%d.%m.%YT%H:%M', time_zone => 'Europe/Berlin', ); for my $tr ( @{ $self->{tree}->findnodes($xp_element) } ) { my @message_nodes = $tr->findnodes($xp_msg); Loading Loading @@ -328,10 +338,14 @@ sub results { $train =~ s{#.*$}{}; my $datetime = $self->{strptime_obj}->parse_datetime("${date}T${time}"); push( @{ $self->{results} }, Travel::Status::DE::HAFAS::Result->new( date => $date, datetime => $datetime, datetime_now => $self->{datetime_now}, raw_delay => $delay, raw_e_delay => $e_delay, messages => \@messages, Loading lib/Travel/Status/DE/HAFAS/Result.pm +21 −1 Original line number Diff line number Diff line Loading @@ -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 ) = @_; Loading @@ -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) = @_; Loading Loading
Build.PL +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ Module::Build->new( 'perl' => '5.10.1', 'Carp' => 0, 'Class::Accessor' => '0.16', 'DateTime' => 0, 'DateTime::Format::Strptime' => 0, 'Getopt::Long' => 0, 'JSON' => 0, 'List::MoreUtils' => 0, Loading
Changelog +5 −0 Original line number Diff line number Diff line git HEAD * New dependencies: DateTime and DateTime::Format::Strptime * Result: New accessors ->datetime, ->countdown and ->countdown_sec Travel::Status::DE::DeutscheBahn 2.01 - Sat Oct 10 2015 * Result: Fix ->type accessor (was not working for all backends) Loading
README +2 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ Dependencies * perl version 5.10.1 or newer * Class::Accessor * DateTime * DateTime::Format::Strptime * JSON * List::MoreUtils * LWP::UserAgent (usually shipped by libwww-perl) Loading
lib/Travel/Status/DE/HAFAS.pm +14 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ use utf8; no if $] >= 5.018, warnings => 'experimental::smartmatch'; use Carp qw(confess); use DateTime; use DateTime::Format::Strptime; use LWP::UserAgent; use POSIX qw(strftime); use Travel::Status::DE::HAFAS::Result; Loading Loading @@ -291,6 +293,14 @@ sub results { $self->{results} = []; $self->{datetime_now} //= DateTime->now( time_zone => 'Europe/Berlin', ); $self->{strptime_obj} //= DateTime::Format::Strptime->new( pattern => '%d.%m.%YT%H:%M', time_zone => 'Europe/Berlin', ); for my $tr ( @{ $self->{tree}->findnodes($xp_element) } ) { my @message_nodes = $tr->findnodes($xp_msg); Loading Loading @@ -328,10 +338,14 @@ sub results { $train =~ s{#.*$}{}; my $datetime = $self->{strptime_obj}->parse_datetime("${date}T${time}"); push( @{ $self->{results} }, Travel::Status::DE::HAFAS::Result->new( date => $date, datetime => $datetime, datetime_now => $self->{datetime_now}, raw_delay => $delay, raw_e_delay => $e_delay, messages => \@messages, Loading
lib/Travel/Status/DE/HAFAS/Result.pm +21 −1 Original line number Diff line number Diff line Loading @@ -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 ) = @_; Loading @@ -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) = @_; Loading