summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-29 12:20:16 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-29 12:26:46 (GMT)
commitac81019e73049c079d3b9ea8c4187a04bc1833f4 (patch)
tree7fce5730e1660e77044fe0c2437062271cfc65aa /lib
parentfbe0303d3cc74f355beb49fcd6ac6d2cebe3851f (diff)
improved show info output
moved command line parsing of week and dow to lib
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/utils.pm41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/RHRD/utils.pm b/lib/RHRD/utils.pm
index 7f060e9..3835851 100755
--- a/lib/RHRD/utils.pm
+++ b/lib/RHRD/utils.pm
@@ -66,6 +66,9 @@ use constant {
DB_PARAM_DOW_HINT => "must be between 1 and 7 (1=Monday, ..., 7=Sunday)",
DB_PARAM_STARTTIME_HINT => "must be in format HHMM (without seperator) in 24 hour format",
DB_PARAM_LEN_HINT => "must be a positive number below 1440",
+
+ CMDLINE_WEEK_HINT => "must be one of W1, W2, W3, W4",
+ CMDLINE_DOW_HINT => "must be one of MO, TU, WE, TH, FR, SA, SU",
};
sub dropbox_param_type_ok
@@ -118,6 +121,44 @@ sub dropbox_param_len_ok
return (1, 'OK', DB_PARAM_LEN_HINT);
}
+sub cmdline_rdweek
+{
+ my ($dow) = @_;
+
+ if(uc($dow) eq "W1") {
+ return (1, 'OK', CMDLINE_WEEK_HINT);
+ } elsif(uc($dow) eq "W2") {
+ return (2, 'OK', CMDLINE_WEEK_HINT);
+ } elsif(uc($dow) eq "W3") {
+ return (3, 'OK', CMDLINE_WEEK_HINT);
+ } elsif(uc($dow) eq "W4") {
+ return (4, 'OK', CMDLINE_WEEK_HINT);
+ }
+ return (undef, 'invalid week', CMDLINE_WEEK_HINT);
+}
+
+sub cmdline_dow
+{
+ my ($dow) = @_;
+
+ if(uc($dow) eq "MO") {
+ return (1, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "TU") {
+ return (2, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "WE") {
+ return (3, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "TH") {
+ return (4, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "FR") {
+ return (5, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "SA") {
+ return (6, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "SU") {
+ return (7, 'OK', CMDLINE_DOW_HINT);
+ }
+ return (undef, 'invalid day-of-week', CMDLINE_DOW_HINT);
+}
+
sub fetch_parse_json
{
my ($url, $ua_str) = @_;