diff options
Diffstat (limited to 'lib/RHRD')
-rwxr-xr-x | lib/RHRD/utils.pm | 41 |
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) = @_; |