A recurring calendar schedule: the allowed seconds, minutes, hours, days of the month, months (1-12) and weekdays (0-6, Sunday is 0) and an optional zone. An empty field allows every value.
Days and weekdays both restricted match either one, as in classic cron,
unless and_ is set. Without a zone, a cron runs in the zone of the
datetime it is given. Build one with cron.parse or cron.make.
Attributes#
| Attribute | Type | Description |
|---|---|---|
tz | tzinfo | None | |
seconds | frozenset[int] | |
minutes | frozenset[int] | |
hours | frozenset[int] | |
days | frozenset[int] | |
months | frozenset[int] | |
weekdays | frozenset[int] | |
and_ | bool |
Functions#
__init__#
__init__(*, minutes, hours, days, months, weekdays, seconds=(0,), and_=False, tz=None) -> NoneRaises ValueError for a value outside its field's range.
Weekday 7 is Sunday, as 0.
| Parameter | Type | Description |
|---|---|---|
minutes | Iterable[int] | |
hours | Iterable[int] | |
days | Iterable[int] | |
months | Iterable[int] | |
weekdays | Iterable[int] | |
seconds | Iterable[int] = (0,) | |
and_ | bool = False | |
tz | tzinfo | None = None |
def __init__(
self,
*,
minutes: Iterable[int],
hours: Iterable[int],
days: Iterable[int],
months: Iterable[int],
weekdays: Iterable[int],
seconds: Iterable[int] = (0,),
and_: bool = False,
tz: tzinfo | None = None,
) -> None:
"""Raises ``ValueError`` for a value outside its field's range.
Weekday 7 is Sunday, as 0."""
fields = {
"seconds": _restrict("seconds", seconds, 0, 59),
"minutes": _restrict("minutes", minutes, 0, 59),
"hours": _restrict("hours", hours, 0, 23),
"days": _restrict("days", days, 1, 31),
"months": _restrict("months", months, 1, 12),
"weekdays": _restrict("weekdays", weekdays, 0, 7, lambda v: 0 if v == 7 else v),
}
for name, values in fields.items():
object.__setattr__(self, name, frozenset(values))
object.__setattr__(self, "and_", and_)
object.__setattr__(self, "tz", tz)
object.__setattr__(self, "_plan", _plan(**fields))