This commit is contained in:
+6
-3
@@ -83,17 +83,20 @@ def occurrences(rule: str, starts: datetime, start: datetime, end: datetime, cut
|
|||||||
count = int(parts.get("COUNT", 100000))
|
count = int(parts.get("COUNT", 100000))
|
||||||
if "UNTIL" in parts:
|
if "UNTIL" in parts:
|
||||||
until = datetime.fromisoformat(parts["UNTIL"])
|
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:
|
else:
|
||||||
until = end
|
until = end
|
||||||
if starts.tzinfo is None:
|
if starts.tzinfo is None:
|
||||||
starts = starts.replace(tzinfo=UTC)
|
starts = starts.replace(tzinfo=UTC)
|
||||||
if until.tzinfo is None:
|
|
||||||
until = until.replace(tzinfo=UTC)
|
|
||||||
if start.tzinfo is None:
|
if start.tzinfo is None:
|
||||||
start = start.replace(tzinfo=UTC)
|
start = start.replace(tzinfo=UTC)
|
||||||
if end.tzinfo is None:
|
if end.tzinfo is None:
|
||||||
end = end.replace(tzinfo=UTC)
|
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 = []
|
result = []
|
||||||
cursor = starts
|
cursor = starts
|
||||||
emitted = 0
|
emitted = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user