Automation: dates and reminders
Many automations depend on the calendar: send a reminder 7 days before a deadline, build a report every Monday, archive whatever is older than 30 days. The datetime module handles all of it without calculation mistakes (28- or 31-day months, leap years).
date(2026, 11, 16) creates a date, timedelta(days=30) is a duration you can add or subtract, and the difference between two dates gives a timedelta whose .days is the number of days. .isoformat() writes the date as 2026-11-16, the safest format for sorting.
from datetime import date, timedelta
start = date(2026, 11, 16)
for week in range(3):
meeting = start + timedelta(weeks=week)
print(meeting.isoformat(), meeting.strftime("%A"))