Schedule repeated local reminders using zone rules, not a fixed UTC offset.
How It Works
A daily 9:00 appointment should stay at 9:00 in its chosen local timezone as daylight saving changes. A loop that adds 24 elapsed hours to UTC instants can shift its displayed local hour. Generate each calendar occurrence in the named zone and convert it to UTC when storing or dispatching.
Some local wall times do not exist or occur twice; fold and application rules matter for those cases.
Step-by-Step Example
from datetime import date, datetime, timedelta, timezone
from zoneinfo import ZoneInfo
zone = ZoneInfo("Europe/Paris")
for day_offset in range(3):
day = date(2026, 3, 28) + timedelta(days=day_offset)
local_due = datetime(day.year, day.month, day.day, 9, tzinfo=zone)
print(day.isoformat(), local_due.astimezone(timezone.utc).strftime("%H:%M"))
Understanding the Example
- The expression 'ZoneInfo("Europe/Paris")' supplies the value stored as 'zone'. This value is then used or checked by the later statements.
- The for loop processes one item per iteration rather than requiring a separate statement for each value.
A successful run of this example prints the following output:
2026-03-28 08:00
2026-03-29 07:00
2026-03-30 07:00
Where This Fits in a Real Program
For event timestamps, distinguish the displayed local clock from the instant that it represents. Store or exchange an unambiguous aware value, then convert it when displaying it to a user. For repeated calendar appointments, use a geographic timezone so daylight-saving rules are not lost.
Practice: Try It Yourself
Test a reminder at 02:30 across a daylight-saving transition and document how it should behave.
For this exercise, predict the result before running the changed code. Then explain the difference between the original and modified cases using the actual values, not just whether the program completed.
Further Reading
Read the official Python documentation for complete parameters, return types and exceptions.
Common Beginner Mistakes
- Adding a 24-hour timedelta to a UTC timestamp and claiming the result is always 9:00 local time.
- Creating appointments in a nonexistent or ambiguous local hour without defining a policy.
Key Takeaways
- Schedule repeated local reminders using zone rules, not a fixed UTC offset.
- A daily 9:00 appointment should stay at 9:00 in its chosen local timezone as daylight saving changes.
- Some local wall times do not exist or occur twice; fold and application rules matter for those cases.