def date_in_range(date_range, date, debug=True):
 out = True
 for item in date_range.split(u','):
  (attribute, comparison_operator, value) = CLAUSE.match(item.strip()).groups()
  if (attribute in (u'weekday', u'isoweekday')):
   left = getattr(date, attribute)()
   right = int(value)
  elif attribute:
   left = getattr(date, attribute)
   right = int(value)
  else:
   left = date
   right = dateutil.parser.parse(value)
  if debug:
   print(u'    <{0} {1} {2}>'.format(left, comparison_operator, right))
  out = (out and OPERATORS[comparison_operator](left, right))
 return out

def date_in_range ( date_range , date , debug = True ) : out = True for item in date_range . split ( u',' ) : ( attribute , comparison_operator , value ) = CLAUSE . match ( item . strip ( ) ) . groups ( ) if ( attribute in ( u'weekday' , u'isoweekday' ) ) : left = getattr ( date , attribute ) ( ) right = int ( value ) elif attribute : left = getattr ( date , attribute ) right = int ( value ) else : left = date right = dateutil . parser . parse ( value ) if debug : print ( u'    <{0} {1} {2}>' . format ( left , comparison_operator , right ) ) out = ( out and OPERATORS [ comparison_operator ] ( left , right ) ) return out
check if date is in the range specified .