Skip to content

Commit 488d3eb

Browse files
committed
2 parents 721ad5c + aac549d commit 488d3eb

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ section for more details)
148148
Converting between timezones is more easily done, using the
149149
standard astimezone method.
150150

151-
>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))
151+
>>> utc_dt = datetime.fromtimestamp(1143408899, tz=utc)
152152
>>> utc_dt.strftime(fmt)
153153
'2006-03-26 21:34:59 UTC+0000'
154154
>>> au_tz = timezone('Australia/Sydney')
@@ -166,7 +166,7 @@ conversions. ``normalize()`` and ``localize()`` are not really
166166
necessary when there are no daylight saving time transitions to
167167
deal with.
168168

169-
>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)
169+
>>> utc_dt = datetime.fromtimestamp(1143408899, tz=utc)
170170
>>> utc_dt.strftime(fmt)
171171
'2006-03-26 21:34:59 UTC+0000'
172172
>>> au_tz = timezone('Australia/Sydney')
@@ -605,4 +605,3 @@ Contact
605605
~~~~~~~
606606

607607
Stuart Bishop <stuart@stuartbishop.net>
608-

src/pytz/tests/test_tzinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ class NoumeaDSTEndTestCase(USEasternDSTStartTestCase):
539539

540540

541541
class NoumeaNoMoreDSTTestCase(NoumeaDSTEndTestCase):
542-
# Noumea dropped DST in 1997. Here we test that it stops occuring.
542+
# Noumea dropped DST in 1997. Here we test that it stops occurring.
543543
transition_time = (
544544
NoumeaDSTEndTestCase.transition_time + timedelta(days=365 * 10))
545545
before = NoumeaDSTEndTestCase.after

src/pytz/tzinfo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''Base classes and helpers for building zone specific tzinfo classes'''
22

3-
from datetime import datetime, timedelta, tzinfo
3+
from datetime import datetime, timedelta, timezone, tzinfo
44
from bisect import bisect_right
55
try:
66
set
@@ -24,7 +24,7 @@ def memorized_timedelta(seconds):
2424
_timedelta_cache[seconds] = delta
2525
return delta
2626

27-
_epoch = datetime.utcfromtimestamp(0)
27+
_epoch = datetime.fromtimestamp(0, tz=timezone.utc).replace(tzinfo=None)
2828
_datetime_cache = {0: _epoch}
2929

3030

@@ -33,8 +33,8 @@ def memorized_datetime(seconds):
3333
try:
3434
return _datetime_cache[seconds]
3535
except KeyError:
36-
# NB. We can't just do datetime.utcfromtimestamp(seconds) as this
37-
# fails with negative values under Windows (Bug #90096)
36+
# NB. We can't just do datetime.fromtimestamp(seconds, tz=timezone.utc).replace(tzinfo=None)
37+
# as this fails with negative values under Windows (Bug #90096)
3838
dt = _epoch + timedelta(seconds=seconds)
3939
_datetime_cache[seconds] = dt
4040
return dt
@@ -355,7 +355,7 @@ def localize(self, dt, is_dst=False):
355355
is_dst=False) + timedelta(hours=6)
356356

357357
# If we get this far, we have multiple possible timezones - this
358-
# is an ambiguous case occuring during the end-of-DST transition.
358+
# is an ambiguous case occurring during the end-of-DST transition.
359359

360360
# If told to be strict, raise an exception since we have an
361361
# ambiguous case

0 commit comments

Comments
 (0)