code: def relative_days(current_wday, wday, dir):
      """Returns the number of days (positive or negative) to the "next" or
      "last" of a certain weekday. ``current_wday`` and ``wday`` are numbers,
      i.e. 0 = monday, 1 = tuesday, 2 = wednesday, etc.
  
      >>> # Get the number of days to the next tuesday, if today is Sunday
      >>> relative_days(6, 1, 1)
      2
  
      :param current_wday: the number of the current weekday.
      :param wday: the target weekday.
      :param dir: -1 for the "last" (past) weekday, 1 for the "next" (future)
          weekday.
      """
  
      if current_wday == wday:
          return 7 * dir
  
      if dir == 1:
          return (wday + 7 - current_wday) % 7
      else:
          return (current_wday + 7 - wday) % 7 * -1
  
imports: import calendar
  import copy
  from datetime import date, datetime, timedelta
  from whoosh.compat import iteritems
label_desc: Use image node_id 1 for calling a global function with example usage: relative_days(current_wday, wday, dir) and returns: unknown, unknown, unknown