parameters: (year, month, dayofweek, hour, minute, whichweek)
return_statement: return wd
docstring: dayofweek == 0 means Sunday, whichweek 5 means last instance
docstring_summary: dayofweek == 0 means Sunday, whichweek 5 means last instance
docstring_tokens: dayofweek == 0 means Sunday whichweek 5 means last instance
function: def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
      """ dayofweek == 0 means Sunday, whichweek 5 means last instance """
      first = datetime.datetime(year, month, 1, hour, minute)
  
      # This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6),
      # Because 7 % 7 = 0
      weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1)
      wd = weekdayone + ((whichweek - 1) * ONEWEEK)
      if (wd.month != month):
          wd -= ONEWEEK
  
      return wd
function_tokens: def picknthweekday ( year , month , dayofweek , hour , minute , whichweek ) : first = datetime . datetime ( year , month , 1 , hour , minute ) # This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6), # Because 7 % 7 = 0 weekdayone = first . replace ( day = ( ( dayofweek - first . isoweekday ( ) ) % 7 ) + 1 ) wd = weekdayone + ( ( whichweek - 1 ) * ONEWEEK ) if ( wd . month != month ) : wd -= ONEWEEK return wd