MCPcopy Create free account
hub / github.com/dateutil/dateutil / __init__

Method __init__

src/dateutil/rrule.py:428–698  ·  view source on GitHub ↗
(self, freq, dtstart=None,
                 interval=1, wkst=None, count=None, until=None, bysetpos=None,
                 bymonth=None, bymonthday=None, byyearday=None, byeaster=None,
                 byweekno=None, byweekday=None,
                 byhour=None, byminute=None, bysecond=None,
                 cache=False)

Source from the content-addressed store, hash-verified

426 times, enabling caching will improve the performance considerably.
427 """
428 def __init__(self, freq, dtstart=None,
429 interval=1, wkst=None, count=None, until=None, bysetpos=None,
430 bymonth=None, bymonthday=None, byyearday=None, byeaster=None,
431 byweekno=None, byweekday=None,
432 byhour=None, byminute=None, bysecond=None,
433 cache=False):
434 super(rrule, self).__init__(cache)
435 global easter
436 if not dtstart:
437 if until and until.tzinfo:
438 dtstart = datetime.datetime.now(tz=until.tzinfo).replace(microsecond=0)
439 else:
440 dtstart = datetime.datetime.now().replace(microsecond=0)
441 elif not isinstance(dtstart, datetime.datetime):
442 dtstart = datetime.datetime.fromordinal(dtstart.toordinal())
443 else:
444 dtstart = dtstart.replace(microsecond=0)
445 self._dtstart = dtstart
446 self._tzinfo = dtstart.tzinfo
447 self._freq = freq
448 self._interval = interval
449 self._count = count
450
451 # Cache the original byxxx rules, if they are provided, as the _byxxx
452 # attributes do not necessarily map to the inputs, and this can be
453 # a problem in generating the strings. Only store things if they've
454 # been supplied (the string retrieval will just use .get())
455 self._original_rule = {}
456
457 if until and not isinstance(until, datetime.datetime):
458 until = datetime.datetime.fromordinal(until.toordinal())
459 self._until = until
460
461 if self._dtstart and self._until:
462 if (self._dtstart.tzinfo is not None) != (self._until.tzinfo is not None):
463 # According to RFC5545 Section 3.3.10:
464 # https://tools.ietf.org/html/rfc5545#section-3.3.10
465 #
466 # > If the "DTSTART" property is specified as a date with UTC
467 # > time or a date with local time and time zone reference,
468 # > then the UNTIL rule part MUST be specified as a date with
469 # > UTC time.
470 raise ValueError(
471 'RRULE UNTIL values must be specified in UTC when DTSTART '
472 'is timezone-aware'
473 )
474
475 if count is not None and until:
476 warn("Using both 'count' and 'until' is inconsistent with RFC 5545"
477 " and has been deprecated in dateutil. Future versions will "
478 "raise an error.", DeprecationWarning)
479
480 if wkst is None:
481 self._wkst = calendar.firstweekday()
482 elif isinstance(wkst, integer_types):
483 self._wkst = wkst
484 else:
485 self._wkst = wkst.weekday

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 5

__construct_bysetMethod · 0.95
weekdayMethod · 0.80
appendMethod · 0.80
weekdayClass · 0.70
replaceMethod · 0.45

Tested by

no test coverage detected