Skip to content

Commit

Permalink
Remove use of pytz.localize and rely entirely on zoneinfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 18, 2024
1 parent c842ec1 commit 60ac79f
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions tempora/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,7 @@ def _next_time(self):
"""
Add delay to self, localized
"""
return self._localize(self + self.delay)

@staticmethod
def _localize(dt):
"""
Rely on ZoneInfo.localize to ensure new result honors DST.
"""
try:
tz = dt.tzinfo
return tz.localize(dt.replace(tzinfo=None))
except AttributeError:
return dt
return self + self.delay

def next(self):
cmd = self.__class__.from_datetime(self._next_time())
Expand Down Expand Up @@ -174,7 +163,7 @@ def daily_at(cls, at, target):
when -= daily
while when < now():
when += daily
return cls.at_time(cls._localize(when), daily, target)
return cls.at_time(when, daily, target)


class Scheduler:
Expand Down

0 comments on commit 60ac79f

Please sign in to comment.