fix: honor recurrence cutoff in occurrence generation
ci / docker (push) Successful in 5m54s

This commit is contained in:
2026-09-05 21:17:31 +08:00
parent 7ab5896dc0
commit ceaaaa593e
+6 -3
View File
@@ -83,17 +83,20 @@ def occurrences(rule: str, starts: datetime, start: datetime, end: datetime, cut
count = int(parts.get("COUNT", 100000))
if "UNTIL" in parts:
until = datetime.fromisoformat(parts["UNTIL"])
until = until.replace(tzinfo=UTC) if until.tzinfo is None else until
until = until.replace(tzinfo=UTC) if until.tzinfo is None else until.astimezone(UTC)
else:
until = end
if starts.tzinfo is None:
starts = starts.replace(tzinfo=UTC)
if until.tzinfo is None:
until = until.replace(tzinfo=UTC)
if start.tzinfo is None:
start = start.replace(tzinfo=UTC)
if end.tzinfo is None:
end = end.replace(tzinfo=UTC)
if cutoff is not None:
cutoff = cutoff.replace(tzinfo=UTC) if cutoff.tzinfo is None else cutoff.astimezone(UTC)
until = min(until, cutoff)
if until.tzinfo is None:
until = until.replace(tzinfo=UTC)
result = []
cursor = starts
emitted = 0