Skip to content

Commit

Permalink
Merge pull request Pycord-Development#456 from veni-vidi-code/patch-1
Browse files Browse the repository at this point in the history
Bugfix for task.loop
  • Loading branch information
Dorukyum authored Nov 18, 2021
2 parents c5bee66 + ef94e38 commit 92f26c2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions discord/ext/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,13 @@ def _get_next_sleep_time(self) -> datetime.datetime:

if self._current_loop == 0:
self._time_index += 1
return datetime.datetime.combine(datetime.datetime.now(datetime.timezone.utc), next_time)
if next_time > datetime.datetime.now(datetime.timezone.utc).timetz():
return datetime.datetime.combine(datetime.datetime.now(datetime.timezone.utc), next_time)
else:
return datetime.datetime.combine(datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1), next_time)

next_date = self._last_iteration
if self._time_index == 0:
# we can assume that the earliest time should be scheduled for "tomorrow"
next_date = cast(datetime.datetime, self._last_iteration)
if next_time < next_date.timetz():
next_date += datetime.timedelta(days=1)

self._time_index += 1
Expand Down

0 comments on commit 92f26c2

Please sign in to comment.