Skip to content

Commit

Permalink
handling cases where time for routine doesn't include tzinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
rsivilli committed Aug 19, 2023
1 parent d918338 commit 73308c3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions twitchio/ext/routines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ def next_execution_time(self) -> datetime.timedelta | None:

if self.next_event_time is None:
return None

return max(self.next_event_time - datetime.datetime.now(datetime.timezone.utc), datetime.timedelta(seconds=0))

return max(self.next_event_time - datetime.datetime.now(self.next_event_time.tzinfo), datetime.timedelta(seconds=0))


@property
def start_time(self) -> Optional[datetime.datetime]:
Expand Down Expand Up @@ -369,7 +370,7 @@ async def _routine(self, *args, **kwargs) -> None:
self.next_event_time = self._time
wait = compute_timedelta(self._time)
await asyncio.sleep(wait)

if self._wait_first and not self._time:
self.next_event_time = self._delta + datetime.datetime.now(datetime.timezone.utc)
await asyncio.sleep(self._delta)
Expand Down

0 comments on commit 73308c3

Please sign in to comment.