IntervalTrigger uses wall-clock arithmetic across DST on master

Author: LindseyZ1205Created Sep 29, 2026Updated Sep 29, 2026

Description

On current master, IntervalTrigger.next() adds a timedelta in local wall time. When using ZoneInfo, this can produce nonexistent spring-forward times, skip an hour during fall-back, or move backwards when starting in the second fold. The end_time checks also compare wall times when the tzinfo objects are identical.

Reproduction

python
from datetime import datetime
from zoneinfo import ZoneInfo
from apscheduler.triggers.interval import IntervalTrigger

zone = ZoneInfo("Europe/Berlin")
trigger = IntervalTrigger(seconds=1, start_time=datetime(2026, 10, 25, 2, 59, 59, tzinfo=zone))
a = trigger.next()
b = trigger.next()
print(a.isoformat(), b.isoformat())
print(b.timestamp() - a.timestamp())  # 3601.0; expected 1.0

A start time in fold=1 can instead move backwards by 3599 seconds. For end_time validation, 02:45 in fold=0 followed by 02:15 in fold=1 is a valid 30-minute interval, but construction raises ValueError.

Scope and proposed fix

Use UTC datetime arithmetic for elapsed intervals and UTC datetime comparisons for end_time, converting generated times back to the start time's timezone. This preserves microseconds without epoch-float arithmetic.

This concerns the v4 master IntervalTrigger implementation. #1114 fixed the v3 scheduler wakeup calculation; #1137 addresses combining triggers. Neither changes this path.

Verified with Python 3.12 on macOS. Regression tests fail on original source and pass with the fix. OpenAI Codex (GPT-6) assisted with investigation, reproduction, and this report.