summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-10-01 09:57:02 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-10-01 09:57:02 +0200
commit77e13ad0cf877f37ac03c45cde766bd2c5a90046 (patch)
tree10b538d2b12ce0a47109239d8edfbd5453ba7e26
parent8a9f6b6272621df0afb3844de291966d7fef24e2 (diff)
efa-m: Make --date and --time actually work
-rw-r--r--Changelog2
-rw-r--r--lib/Travel/Status/DE/VRR.pm42
2 files changed, 39 insertions, 5 deletions
diff --git a/Changelog b/Changelog
index 3db8b05..281caf2 100644
--- a/Changelog
+++ b/Changelog
@@ -1,7 +1,9 @@
git HEAD
+ [efa-m]
* Add --platform / --line options to filter output
* Align times properly if departure list contains a daychange
+ * Make --date and --time actually work
Travel::Status::DE::VRR 0.01 - Sun Sep 11 2011
diff --git a/lib/Travel/Status/DE/VRR.pm b/lib/Travel/Status/DE/VRR.pm
index b63e716..f886379 100644
--- a/lib/Travel/Status/DE/VRR.pm
+++ b/lib/Travel/Status/DE/VRR.pm
@@ -17,6 +17,9 @@ sub new {
my $mech = WWW::Mechanize->new();
my @now = localtime( time() );
+ my @time = @now[ 2, 1 ];
+ my @date = ( $now[3], $now[4] + 1, $now[5] + 1900 );
+
if ( not( $opt{place} and $opt{name} ) ) {
confess('You need to specify a place and a name');
}
@@ -24,22 +27,51 @@ sub new {
confess('type must be stop, address or poi');
}
+ ## no critic (RegularExpressions::ProhibitUnusedCapture)
+ ## no critic (Variables::ProhibitPunctuationVars)
+
+ if ( $opt{time}
+ and $opt{time} =~ m{ ^ (?<hour> \d\d? ) : (?<minute> \d\d ) $ }x )
+ {
+ @time = @+{qw{hour minute}};
+ }
+ elsif ( $opt{time} ) {
+ confess('Invalid time specified');
+ }
+
+ if (
+ $opt{date}
+ and $opt{date} =~ m{ ^ (?<day> \d\d? ) [.] (?<month> \d\d? ) [.]
+ (?<year> \d{4} )? $ }x
+ )
+ {
+ if ( $+{year} ) {
+ @date = @+{qw{day month year}};
+ }
+ else {
+ @date[ 0, 1 ] = @+{qw{day month}};
+ }
+ }
+ elsif ( $opt{date} ) {
+ confess('Invalid date specified');
+ }
+
my $self = {
post => {
command => q{},
deleteAssignedStops_dm => '1',
help => 'Hilfe',
- itdDateDay => $now[3],
- itdDateMonth => $now[4] + 1,
- itdDateYear => $now[5] + 1900,
+ itdDateDay => $date[0],
+ itdDateMonth => $date[1],
+ itdDateYear => $date[2],
itdLPxx_id_dm => ':dm',
itdLPxx_mapState_dm => q{},
itdLPxx_mdvMap2_dm => q{},
itdLPxx_mdvMap_dm => '3406199:401077:NAV3',
itdLPxx_transpCompany => 'vrr',
itdLPxx_view => q{},
- itdTimeHour => $now[2],
- itdTimeMinute => $now[1],
+ itdTimeHour => $time[0],
+ itdTimeMinute => $time[1],
language => 'de',
nameInfo_dm => 'invalid',
nameState_dm => 'empty',