Skip to content

Commit

Permalink
Hardcode epoch constant
Browse files Browse the repository at this point in the history
Rather than calculate it, hard code the Unix epoch as a timedelta
for Python 2.7 compatibility.
  • Loading branch information
stub42 committed Aug 21, 2023
1 parent 488d3eb commit fbddefc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pytz/tzinfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''Base classes and helpers for building zone specific tzinfo classes'''

from datetime import datetime, timedelta, timezone, tzinfo
from datetime import datetime, timedelta, tzinfo
from bisect import bisect_right
try:
set
Expand All @@ -24,7 +24,8 @@ def memorized_timedelta(seconds):
_timedelta_cache[seconds] = delta
return delta

_epoch = datetime.fromtimestamp(0, tz=timezone.utc).replace(tzinfo=None)

_epoch = datetime(1970, 1, 1, 0, 0) # datetime.utcfromtimestamp(0)
_datetime_cache = {0: _epoch}


Expand All @@ -39,6 +40,7 @@ def memorized_datetime(seconds):
_datetime_cache[seconds] = dt
return dt


_ttinfo_cache = {}


Expand All @@ -55,6 +57,7 @@ def memorized_ttinfo(*args):
_ttinfo_cache[args] = ttinfo
return ttinfo


_notime = memorized_timedelta(0)


Expand Down

0 comments on commit fbddefc

Please sign in to comment.