Feature Request
Add support for months and years as scheduling intervals, enabling:
import schedule
# Run on the 1st of every month
schedule.every().month.at(":00:00").do(monthly_report)
# Run every 3 months
schedule.every(3).months.do(quarterly_task)
# Run once a year
schedule.every().year.do(annual_cleanup)
Current Behavior
The library supports seconds, minutes, hours, days, and weeks as interval units. There is no support for months or years.
Implementation Notes
The fix requires changes to schedule/__init__.py:
- Add
months and years properties to the Job class (similar to existing days, weeks, etc.)
- Add the corresponding unit strings to the valid units
- Handle the period calculation in
_schedule_next_run() — months/years can't use simple timedelta since month lengths vary. Use dateutil.relativedelta or manual date arithmetic.
- Add comprehensive tests in
test_schedule.py covering:
every().month.do(job) — runs monthly
every(3).months.do(job) — runs every 3 months
every().year.do(job) — runs yearly
- Edge cases: Feb 29 (leap year), month-end dates (Jan 31 → Feb 28)
- Update the
__init__.py docstring to document the new intervals
Important: Do NOT add any external dependencies. Use Python's standard library calendar module for month-length calculations. The dateutil library is NOT a dependency of this project.
References
Feature Request
Add support for
monthsandyearsas scheduling intervals, enabling:Current Behavior
The library supports
seconds,minutes,hours,days, andweeksas interval units. There is no support formonthsoryears.Implementation Notes
The fix requires changes to
schedule/__init__.py:monthsandyearsproperties to theJobclass (similar to existingdays,weeks, etc.)_schedule_next_run()— months/years can't use simpletimedeltasince month lengths vary. Usedateutil.relativedeltaor manual date arithmetic.test_schedule.pycovering:every().month.do(job)— runs monthlyevery(3).months.do(job)— runs every 3 monthsevery().year.do(job)— runs yearly__init__.pydocstring to document the new intervalsImportant: Do NOT add any external dependencies. Use Python's standard library
calendarmodule for month-length calculations. Thedateutillibrary is NOT a dependency of this project.References