def crontab(minute='<STR_LIT:*>', hour='<STR_LIT:*>', day='<STR_LIT:*>', month='<STR_LIT:*>', day_of_week='<STR_LIT:*>'):
validation = (<EOL>('<STR_LIT:m>', month, range(<NUM_LIT:1>, <NUM_LIT>)),<EOL>('<STR_LIT:d>', day, range(<NUM_LIT:1>, <NUM_LIT:32>)),<EOL>('<STR_LIT:w>', day_of_week, range(<NUM_LIT:8>)), <EOL>('<STR_LIT:H>', hour, range(<NUM_LIT>)),<EOL>('<STR_LIT:M>', minute, range(<NUM_LIT>))<EOL>)<EOL>cron_settings = []<EOL>for (date_str, value, acceptable) in validation:<EOL><INDENT>settings = set([])<EOL>if isinstance(value, int):<EOL><INDENT>value = str(value)<EOL><DEDENT>for piece in value.split('<STR_LIT:U+002C>'):<EOL><INDENT>if piece == '<STR_LIT:*>':<EOL><INDENT>settings.update(acceptable)<EOL>continue<EOL><DEDENT>if piece.isdigit():<EOL><INDENT>piece = int(piece)<EOL>if piece not in acceptable:<EOL><INDENT>raise ValueError('<STR_LIT>' % piece)<EOL><DEDENT>elif date_str == '<STR_LIT:w>':<EOL><INDENT>piece %= <NUM_LIT:7><EOL><DEDENT>settings.add(piece)<EOL><DEDENT>else:<EOL><INDENT>dash_match = dash_re.match(piece)<EOL>if dash_match:<EOL><INDENT>lhs, rhs = map(int, dash_match.groups())<EOL>if lhs not in acceptable or rhs not in acceptable:<EOL><INDENT>raise ValueError('<STR_LIT>' % piece)<EOL><DEDENT>elif date_str == '<STR_LIT:w>':<EOL><INDENT>lhs %= <NUM_LIT:7><EOL>rhs %= <NUM_LIT:7><EOL><DEDENT>settings.update(range(lhs, rhs + <NUM_LIT:1>))<EOL>continue<EOL><DEDENT>every_match = every_re.match(piece)<EOL>if every_match:<EOL><INDENT>if date_str == '<STR_LIT:w>':<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>interval = int(every_match.groups()[<NUM_LIT:0>])<EOL>settings.update(acceptable[::interval])<EOL><DEDENT><DEDENT><DEDENT>cron_settings.append(sorted(list(settings)))<EOL><DEDENT>def validate_date(timestamp):<EOL><INDENT>_, m, d, H, M, _, w, _, _ = timestamp.timetuple()<EOL>w = (w + <NUM_LIT:1>) % <NUM_LIT:7><EOL>for (date_piece, selection) in zip((m, d, w, H, M), cron_settings):<EOL><INDENT>if date_piece not in selection:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>return validate_date<EOL>
Convert a "crontab"-style set of parameters into a test function that will
return True when the given datetime matches the parameters set forth in
the crontab.

For day-of-week, 0=Sunday and 6=Saturday.

Acceptable inputs:
* = every distinct value
*/n = run every "n" times, i.e. hours='*/4' == 0, 4, 8, 12, 16, 20
m-n = run every time m..n
m,n = run on m and n