Skip to content

Commit 15a72cd

Browse files
authored
fix: ensure next_fire in TimeTrigger returns proper next time (#1575)
* fix: ensure time trigger target is greater than last call time * refactor: adjust fix to be more "proper" * docs: document the weird fix
1 parent f049570 commit 15a72cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

interactions/models/internal/tasks/triggers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def next_fire(self) -> datetime | None:
105105
)
106106
if target.tzinfo == timezone.utc:
107107
target = target.astimezone(now.tzinfo)
108-
target = target.replace(tzinfo=None)
108+
# target can fall behind or go forward a day, but all we need is the time itself
109+
# to be converted
110+
# to ensure it's on the same day as "now" and not break the next if statement,
111+
# we can just replace the date with now's date
112+
target = target.replace(year=now.year, month=now.month, day=now.day, tzinfo=None)
109113

110114
if target <= self.last_call_time:
111115
target += timedelta(days=1)

0 commit comments

Comments
 (0)