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
Source code in fluid/scheduler/scheduler_crontab.py
def__init__(self,minute:CI="*",hour:CI="*",day:CI="*",month:CI="*",day_of_week:CI="*",tz:tzinfo=timezone.utc,)->None:self.tz:tzinfo=tzself._info=(f"minute {minute}; hour {hour}; day {day}; month {month}; "f"day_of_week {day_of_week}")validation=(("m",month,range(1,13)),("d",day,range(1,32)),("w",day_of_week,range(8)),# 0-6, but also 7 for Sunday.("H",hour,range(24)),("M",minute,range(60)),)cron_settings=[]fordate_str,value,acceptableinvalidation:settings:Set[int]=set()ifisinstance(value,int):value=str(value)forpieceinvalue.split(","):ifpiece=="*":settings.update(acceptable)continueifpiece.isdigit():digit=int(piece)ifdigitnotinacceptable:raiseValueError("%d is not a valid input"%digit)elifdate_str=="w":digit%=7settings.add(digit)else:dash_match=dash_re.match(piece)ifdash_match:lhs,rhs=map(int,dash_match.groups())iflhsnotinacceptableorrhsnotinacceptable:raiseValueError("%s is not a valid input"%piece)elifdate_str=="w":lhs%=7rhs%=7settings.update(range(lhs,rhs+1))continue# Handle stuff like */3, */6.every_match=every_re.match(piece)ifevery_match:ifdate_str=="w":raiseValueError("Cannot perform this kind of matching"" on day-of-week.")interval=int(every_match.groups()[0])settings.update(acceptable[::interval])cron_settings.append(sorted(list(settings)))self.cron_settings=tuple(cron_settings)