summaryrefslogtreecommitdiff
path: root/lib/Travel/Status
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 /lib/Travel/Status
parent8a9f6b6272621df0afb3844de291966d7fef24e2 (diff)
efa-m: Make --date and --time actually work
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r--lib/Travel/Status/DE/VRR.pm42
1 files changed, 37 insertions, 5 deletions
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',