API reference: Weekly helper¶
- schedium.triggers.Weekly(day, *, at=None, force_0_minute=False)[source][source]¶
Convenience trigger: run weekly on a specific weekday, optionally at a time.
- Parameters:
- daystr | int
Weekday to run on. Can be a string like “mon”/”monday” (case-insensitive, only first 3 letters are considered) or an integer in ISO format where Monday=1 and Sunday=7.
- atstr | datetime.time, optional
Time of day to run at. If not provided, it will not constrain the time. Can be a
datetime.timeobject, or a string in “HH:MM” or “HH:MM:SS[.mmm]” format.- force_0_minutebool, default False
By default, if at is provided without a minute component (e.g. “09:00” or time(9, 0)), the trigger does not constrain the minute (i.e., it can run any minute during the 9 o’clock hour). Setting force_0_minute=True makes it so that the minute is constrained to 0, meaning it will only run at the top of the hour (e.g. 09:00:37).
- Parameters:
day (str | int)
at (str | time | None)
force_0_minute (bool)
- Return type:
Notes
This helper composes triggers to express a weekly schedule.
Tick(Granularity.WEEK) provides a WEEK “bucket” for deduplication.
- On(day_of_week=…) and, if at is provided, hour/minute
(and optionally second/millisecond).
Using Tick(WEEK) (instead of Every(unit=”week”, interval=1)) avoids forcing alignment to week boundaries (e.g. Monday 00:00). That alignment can make next_window() for AND-combinations like “Monday at 09:30” converge poorly by repeatedly jumping to week boundaries.
Examples
>>> Weekly("monday")
Specify a time to run at
>>> Weekly("mon", at="09:30") >>> from datetime import time >>> Weekly("thursday", at=time(9, 30))
Don’t run if overdue by more than a minute (e.g., scheduler was down)
>>> Weekly("thursday", at=time(9, 0), force_0_minute=True)