class_docstr: That's the base of the rrule operation. It accepts all the keywords
  defined in the RFC as its constructor parameters (except byday,
  which was renamed to byweekday) and more. The constructor prototype is::
  
          rrule(freq)
  
  Where freq must be one of YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
  or SECONDLY.
  
  .. note::
      Per RFC section 3.3.10, recurrence instances falling on invalid dates
      and times are ignored rather than coerced:
  
          Recurrence rules may generate recurrence instances with an invalid
          date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM
          on a day where the local time is moved forward by an hour at 1:00
          AM).  Such recurrence instances MUST be ignored and MUST NOT be
          counted as part of the recurrence set.
  
      This can lead to possibly surprising behavior when, for example, the
      start date occurs at the end of the month:
  
      >>> from dateutil.rrule import rrule, MONTHLY
      >>> from datetime import datetime
      >>> start_date = datetime(2014, 12, 31)
      >>> list(rrule(freq=MONTHLY, count=4, dtstart=start_date))
      ... # doctest: +NORMALIZE_WHITESPACE
      [datetime.datetime(2014, 12, 31, 0, 0),
       datetime.datetime(2015, 1, 31, 0, 0),
       datetime.datetime(2015, 3, 31, 0, 0),
       datetime.datetime(2015, 5, 31, 0, 0)]
  
  Additionally, it supports the following keyword arguments:
  
  :param dtstart:
      The recurrence start. Besides being the base for the recurrence,
      missing parameters in the final recurrence instances will also be
      extracted from this date. If not given, datetime.now() will be used
      instead.
  :param interval:
      The interval between each freq iteration. For example, when using
      YEARLY, an interval of 2 means once every two years, but with HOURLY,
      it means once every two hours. The default interval is 1.
  :param wkst:
      The week start day. Must be one of the MO, TU, WE constants, or an
      integer, specifying the first day of the week. This will affect
      recurrences based on weekly periods. The default week start is got
      from calendar.firstweekday(), and may be modified by
      calendar.setfirstweekday().
  :param count:
      If given, this determines how many occurrences will be generated.
  
      .. note::
          As of version 2.5.0, the use of the keyword ``until`` in conjunction
          with ``count`` is deprecated, to make sure ``dateutil`` is fully
          compliant with `RFC-5545 Sec. 3.3.10 <https://tools.ietf.org/
          html/rfc5545#section-3.3.10>`_. Therefore, ``until`` and ``count``
          **must not** occur in the same call to ``rrule``.
  :param until:
      If given, this must be a datetime instance specifying the upper-bound
      limit of the recurrence. The last recurrence in the rule is the greatest
      datetime that is less than or equal to the value specified in the
      ``until`` parameter.
  
      .. note::
          As of version 2.5.0, the use of the keyword ``until`` in conjunction
          with ``count`` is deprecated, to make sure ``dateutil`` is fully
          compliant with `RFC-5545 Sec. 3.3.10 <https://tools.ietf.org/
          html/rfc5545#section-3.3.10>`_. Therefore, ``until`` and ``count``
          **must not** occur in the same call to ``rrule``.
  :param bysetpos:
      If given, it must be either an integer, or a sequence of integers,
      positive or negative. Each given integer will specify an occurrence
      number, corresponding to the nth occurrence of the rule inside the
      frequency period. For example, a bysetpos of -1 if combined with a
      MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will
      result in the last work day of every month.
  :param bymonth:
      If given, it must be either an integer, or a sequence of integers,
      meaning the months to apply the recurrence to.
  :param bymonthday:
      If given, it must be either an integer, or a sequence of integers,
      meaning the month days to apply the recurrence to.
  :param byyearday:
      If given, it must be either an integer, or a sequence of integers,
      meaning the year days to apply the recurrence to.
  :param byeaster:
      If given, it must be either an integer, or a sequence of integers,
      positive or negative. Each integer will define an offset from the
      Easter Sunday. Passing the offset 0 to byeaster will yield the Easter
      Sunday itself. This is an extension to the RFC specification.
  :param byweekno:
      If given, it must be either an integer, or a sequence of integers,
      meaning the week numbers to apply the recurrence to. Week numbers
      have the meaning described in ISO8601, that is, the first week of
      the year is that containing at least four days of the new year.
  :param byweekday:
      If given, it must be either an integer (0 == MO), a sequence of
      integers, one of the weekday constants (MO, TU, etc), or a sequence
      of these constants. When given, these variables will define the
      weekdays where the recurrence will be applied. It's also possible to
      use an argument n for the weekday instances, which will mean the nth
      occurrence of this weekday in the period. For example, with MONTHLY,
      or with YEARLY and BYMONTH, using FR(+1) in byweekday will specify the
      first friday of the month where the recurrence happens. Notice that in
      the RFC documentation, this is specified as BYDAY, but was renamed to
      avoid the ambiguity of that keyword.
  :param byhour:
      If given, it must be either an integer, or a sequence of integers,
      meaning the hours to apply the recurrence to.
  :param byminute:
      If given, it must be either an integer, or a sequence of integers,
      meaning the minutes to apply the recurrence to.
  :param bysecond:
      If given, it must be either an integer, or a sequence of integers,
      meaning the seconds to apply the recurrence to.
  :param cache:
      If given, it must be a boolean value specifying to enable or disable
      caching of results. If you will use the same rrule instance multiple
      times, enabling caching will improve the performance considerably.
   
class_docstr_tok: ["That","'s","the","base","of","the","rrule","operation",".","It","accepts","all","the","keywords","defined","in","the","RFC","as","its","constructor","parameters","(","except","byday",",","which","was","renamed","to","byweekday",")","and","more",".","The","constructor","prototype","is",":",":","rrule","(","freq",")","Where","freq","must","be","one","of","YEARLY",",","MONTHLY",",","WEEKLY",",","DAILY",",","HOURLY",",","MINUTELY",",","or","SECONDLY",".","..","note",":",":","Per","RFC","section","3.3.10",",","recurrence","instances","falling","on","invalid","dates","and","times","are","ignored","rather","than","coerced",":","Recurrence","rules","may","generate","recurrence","instances","with","an","invalid","date","(","e.g.",",","February","30",")","or","nonexistent","local","time","(","e.g.",",","1:30","AM","on","a","day","where","the","local","time","is","moved","forward","by","an","hour","at","1:00","AM",")",".","Such","recurrence","instances","MUST","be","ignored","and","MUST","NOT","be","counted","as","part","of","the","recurrence","set",".","This","can","lead","to","possibly","surprising","behavior","when",",","for","example",",","the","start","date","occurs","at","the","end","of","the","month",":",">",">",">","from","dateutil.rrule","import","rrule",",","MONTHLY",">",">",">","from","datetime","import","datetime",">",">",">","start_date","=","datetime","(","2014",",","12",",","31",")",">",">",">","list","(","rrule","(","freq=MONTHLY",",","count=4",",","dtstart=start_date",")",")","...","#","doctest",":","+NORMALIZE_WHITESPACE","[","datetime.datetime","(","2014",",","12",",","31",",","0",",","0",")",",","datetime.datetime","(","2015",",","1",",","31",",","0",",","0",")",",","datetime.datetime","(","2015",",","3",",","31",",","0",",","0",")",",","datetime.datetime","(","2015",",","5",",","31",",","0",",","0",")","]","Additionally",",","it","supports","the","following","keyword","arguments",":",":","param","dtstart",":","The","recurrence","start",".","Besides","being","the","base","for","the","recurrence",",","missing","parameters","in","the","final","recurrence","instances","will","also","be","extracted","from","this","date",".","If","not","given",",","datetime.now","(",")","will","be","used","instead",".",":","param","interval",":","The","interval","between","each","freq","iteration",".","For","example",",","when","using","YEARLY",",","an","interval","of","2","means","once","every","two","years",",","but","with","HOURLY",",","it","means","once","every","two","hours",".","The","default","interval","is","1.",":","param","wkst",":","The","week","start","day",".","Must","be","one","of","the","MO",",","TU",",","WE","constants",",","or","an","integer",",","specifying","the","first","day","of","the","week",".","This","will","affect","recurrences","based","on","weekly","periods",".","The","default","week","start","is","got","from","calendar.firstweekday","(",")",",","and","may","be","modified","by","calendar.setfirstweekday","(",")",".",":","param","count",":","If","given",",","this","determines","how","many","occurrences","will","be","generated",".","..","note",":",":","As","of","version","2.5.0",",","the","use","of","the","keyword","``","until","``","in","conjunction","with","``","count","``","is","deprecated",",","to","make","sure","``","dateutil","``","is","fully","compliant","with","`","RFC-5545","Sec",".","3.3.10","<","https",":","\/\/tools.ietf.org\/","html\/rfc5545","#","section-3.3.10",">","`","_",".","Therefore",",","``","until","``","and","``","count","``","*","*","must","not","*","*","occur","in","the","same","call","to","``","rrule","``",".",":","param","until",":","If","given",",","this","must","be","a","datetime","instance","specifying","the","upper-bound","limit","of","the","recurrence",".","The","last","recurrence","in","the","rule","is","the","greatest","datetime","that","is","less","than","or","equal","to","the","value","specified","in","the","``","until","``","parameter",".","..","note",":",":","As","of","version","2.5.0",",","the","use","of","the","keyword","``","until","``","in","conjunction","with","``","count","``","is","deprecated",",","to","make","sure","``","dateutil","``","is","fully","compliant","with","`","RFC-5545","Sec",".","3.3.10","<","https",":","\/\/tools.ietf.org\/","html\/rfc5545","#","section-3.3.10",">","`","_",".","Therefore",",","``","until","``","and","``","count","``","*","*","must","not","*","*","occur","in","the","same","call","to","``","rrule","``",".",":","param","bysetpos",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","positive","or","negative",".","Each","given","integer","will","specify","an","occurrence","number",",","corresponding","to","the","nth","occurrence","of","the","rule","inside","the","frequency","period",".","For","example",",","a","bysetpos","of","-1","if","combined","with","a","MONTHLY","frequency",",","and","a","byweekday","of","(","MO",",","TU",",","WE",",","TH",",","FR",")",",","will","result","in","the","last","work","day","of","every","month",".",":","param","bymonth",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","months","to","apply","the","recurrence","to",".",":","param","bymonthday",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","month","days","to","apply","the","recurrence","to",".",":","param","byyearday",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","year","days","to","apply","the","recurrence","to",".",":","param","byeaster",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","positive","or","negative",".","Each","integer","will","define","an","offset","from","the","Easter","Sunday",".","Passing","the","offset","0","to","byeaster","will","yield","the","Easter","Sunday","itself",".","This","is","an","extension","to","the","RFC","specification",".",":","param","byweekno",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","week","numbers","to","apply","the","recurrence","to",".","Week","numbers","have","the","meaning","described","in","ISO8601",",","that","is",",","the","first","week","of","the","year","is","that","containing","at","least","four","days","of","the","new","year",".",":","param","byweekday",":","If","given",",","it","must","be","either","an","integer","(","0","==","MO",")",",","a","sequence","of","integers",",","one","of","the","weekday","constants","(","MO",",","TU",",","etc",")",",","or","a","sequence","of","these","constants",".","When","given",",","these","variables","will","define","the","weekdays","where","the","recurrence","will","be","applied",".","It","'s","also","possible","to","use","an","argument","n","for","the","weekday","instances",",","which","will","mean","the","nth","occurrence","of","this","weekday","in","the","period",".","For","example",",","with","MONTHLY",",","or","with","YEARLY","and","BYMONTH",",","using","FR","(","+1",")","in","byweekday","will","specify","the","first","friday","of","the","month","where","the","recurrence","happens",".","Notice","that","in","the","RFC","documentation",",","this","is","specified","as","BYDAY",",","but","was","renamed","to","avoid","the","ambiguity","of","that","keyword",".",":","param","byhour",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","hours","to","apply","the","recurrence","to",".",":","param","byminute",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","minutes","to","apply","the","recurrence","to",".",":","param","bysecond",":","If","given",",","it","must","be","either","an","integer",",","or","a","sequence","of","integers",",","meaning","the","seconds","to","apply","the","recurrence","to",".",":","param","cache",":","If","given",",","it","must","be","a","boolean","value","specifying","to","enable","or","disable","caching","of","results",".","If","you","will","use","the","same","rrule","instance","multiple","times",",","enabling","caching","will","improve","the","performance","considerably","."]
code: def _iter(self):
      (
          year,
          month,
          day,
          hour,
          minute,
          second,
          weekday,
          yearday,
          _,
      ) = self._dtstart.timetuple()
  
      # Some local variables to speed things up a bit
      freq = self._freq
      interval = self._interval
      wkst = self._wkst
      until = self._until
      bymonth = self._bymonth
      byweekno = self._byweekno
      byyearday = self._byyearday
      byweekday = self._byweekday
      byeaster = self._byeaster
      bymonthday = self._bymonthday
      bynmonthday = self._bynmonthday
      bysetpos = self._bysetpos
      byhour = self._byhour
      byminute = self._byminute
      bysecond = self._bysecond
  
      ii = _iterinfo(self)
      ii.rebuild(year, month)
  
      getdayset = {
          YEARLY: ii.ydayset,
          MONTHLY: ii.mdayset,
          WEEKLY: ii.wdayset,
          DAILY: ii.ddayset,
          HOURLY: ii.ddayset,
          MINUTELY: ii.ddayset,
          SECONDLY: ii.ddayset,
      }[freq]
  
      if freq < HOURLY:
          timeset = self._timeset
      else:
          gettimeset = {
              HOURLY: ii.htimeset,
              MINUTELY: ii.mtimeset,
              SECONDLY: ii.stimeset,
          }[freq]
          if (
              (
                  freq >= HOURLY
                  and self._byhour
                  and hour not in self._byhour
              )
              or (
                  freq >= MINUTELY
                  and self._byminute
                  and minute not in self._byminute
              )
              or (
                  freq >= SECONDLY
                  and self._bysecond
                  and second not in self._bysecond
              )
          ):
              timeset = ()
          else:
              timeset = gettimeset(hour, minute, second)
  
      total = 0
      count = self._count
      while True:
          # Get dayset with the right frequency
          dayset, start, end = getdayset(year, month, day)
  
          # Do the "hard" work ;-)
          filtered = False
          for i in dayset[start:end]:
              if (
                  (bymonth and ii.mmask[i] not in bymonth)
                  or (byweekno and not ii.wnomask[i])
                  or (byweekday and ii.wdaymask[i] not in byweekday)
                  or (ii.nwdaymask and not ii.nwdaymask[i])
                  or (byeaster and not ii.eastermask[i])
                  or (
                      (bymonthday or bynmonthday)
                      and ii.mdaymask[i] not in bymonthday
                      and ii.nmdaymask[i] not in bynmonthday
                  )
                  or (
                      byyearday
                      and (
                          (
                              i < ii.yearlen
                              and i + 1 not in byyearday
                              and -ii.yearlen + i not in byyearday
                          )
                          or (
                              i >= ii.yearlen
                              and i + 1 - ii.yearlen not in byyearday
                              and -ii.nextyearlen + i - ii.yearlen
                              not in byyearday
                          )
                      )
                  )
              ):
                  dayset[i] = None
                  filtered = True
  
          # Output results
          if bysetpos and timeset:
              poslist = []
              for pos in bysetpos:
                  if pos < 0:
                      daypos, timepos = divmod(pos, len(timeset))
                  else:
                      daypos, timepos = divmod(pos - 1, len(timeset))
                  try:
                      i = [
                          x for x in dayset[start:end] if x is not None
                      ][daypos]
                      time = timeset[timepos]
                  except IndexError:
                      pass
                  else:
                      date = datetime.date.fromordinal(
                          ii.yearordinal + i
                      )
                      res = datetime.datetime.combine(date, time)
                      if res not in poslist:
                          poslist.append(res)
              poslist.sort()
              for res in poslist:
                  if until and res > until:
                      self._len = total
                      return
                  elif res >= self._dtstart:
                      if count is not None:
                          count -= 1
                          if count < 0:
                              self._len = total
                              return
                      total += 1
                      yield res
          else:
              for i in dayset[start:end]:
                  if i is not None:
                      date = datetime.date.fromordinal(
                          ii.yearordinal + i
                      )
                      for time in timeset:
                          res = datetime.datetime.combine(date, time)
                          if until and res > until:
                              self._len = total
                              return
                          elif res >= self._dtstart:
                              if count is not None:
                                  count -= 1
                                  if count < 0:
                                      self._len = total
                                      return
  
                              total += 1
                              yield res
  
          # Handle frequency and interval
          fixday = False
          if freq == YEARLY:
              year += interval
              if year > datetime.MAXYEAR:
                  self._len = total
                  return
              ii.rebuild(year, month)
          elif freq == MONTHLY:
              month += interval
              if month > 12:
                  div, mod = divmod(month, 12)
                  month = mod
                  year += div
                  if month == 0:
                      month = 12
                      year -= 1
                  if year > datetime.MAXYEAR:
                      self._len = total
                      return
              ii.rebuild(year, month)
          elif freq == WEEKLY:
              if wkst > weekday:
                  day += (
                      -(weekday + 1 + (6 - wkst)) + self._interval * 7
                  )
              else:
                  day += -(weekday - wkst) + self._interval * 7
              weekday = wkst
              fixday = True
          elif freq == DAILY:
              day += interval
              fixday = True
          elif freq == HOURLY:
              if filtered:
                  # Jump to one iteration before next day
                  hour += ((23 - hour) // interval) * interval
  
              if byhour:
                  ndays, hour = self.__mod_distance(
                      value=hour, byxxx=self._byhour, base=24
                  )
              else:
                  ndays, hour = divmod(hour + interval, 24)
  
              if ndays:
                  day += ndays
                  fixday = True
  
              timeset = gettimeset(hour, minute, second)
          elif freq == MINUTELY:
              if filtered:
                  # Jump to one iteration before next day
                  minute += (
                      (1439 - (hour * 60 + minute)) // interval
                  ) * interval
  
              valid = False
              rep_rate = 24 * 60
              for j in range(rep_rate // gcd(interval, rep_rate)):
                  if byminute:
                      nhours, minute = self.__mod_distance(
                          value=minute, byxxx=self._byminute, base=60
                      )
                  else:
                      nhours, minute = divmod(minute + interval, 60)
  
                  div, hour = divmod(hour + nhours, 24)
                  if div:
                      day += div
                      fixday = True
                      filtered = False
  
                  if not byhour or hour in byhour:
                      valid = True
                      break
  
              if not valid:
                  raise ValueError(
                      "Invalid combination of interval and "
                      + "byhour resulting in empty rule."
                  )
  
              timeset = gettimeset(hour, minute, second)
          elif freq == SECONDLY:
              if filtered:
                  # Jump to one iteration before next day
                  second += (
                      (86399 - (hour * 3600 + minute * 60 + second))
                      // interval
                  ) * interval
  
              rep_rate = 24 * 3600
              valid = False
              for j in range(0, rep_rate // gcd(interval, rep_rate)):
                  if bysecond:
                      nminutes, second = self.__mod_distance(
                          value=second, byxxx=self._bysecond, base=60
                      )
                  else:
                      nminutes, second = divmod(second + interval, 60)
  
                  div, minute = divmod(minute + nminutes, 60)
                  if div:
                      hour += div
                      div, hour = divmod(hour, 24)
                      if div:
                          day += div
                          fixday = True
  
                  if (
                      (not byhour or hour in byhour)
                      and (not byminute or minute in byminute)
                      and (not bysecond or second in bysecond)
                  ):
                      valid = True
                      break
  
              if not valid:
                  raise ValueError(
                      "Invalid combination of interval, "
                      + "byhour and byminute resulting in empty"
                      + " rule."
                  )
  
              timeset = gettimeset(hour, minute, second)
  
          if fixday and day > 28:
              daysinmonth = calendar.monthrange(year, month)[1]
              if day > daysinmonth:
                  while day > daysinmonth:
                      day -= daysinmonth
                      month += 1
                      if month == 13:
                          month = 1
                          year += 1
                          if year > datetime.MAXYEAR:
                              self._len = total
                              return
                      daysinmonth = calendar.monthrange(year, month)[1]
                  ii.rebuild(year, month)
  
imports: import calendar
  import datetime
  import heapq
  import itertools
  import re
  import sys
  from functools import wraps
  from warnings import warn
  from six import advance_iterator, integer_types
  from six.moves import _thread, range
  from ._common import weekday
label_desc: Use image node_id 4 for calling the rrule obj's underlying member method code with example usage: obj._iter() without return types