code: 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
  
imports: import datetime
  import struct
  from six.moves import winreg
  from six import text_type
  from ._common import tzrangebase
label_desc: Use image node_id 2 for calling a global function with example usage: picknthweekday(year, month, dayofweek, hour, minute, whichweek) and returns: wd