8000 Remove all internal uses of utcfromtimestamp · python/cpython@6294fc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6294fc7

Browse files
committed
Remove all internal uses of utcfromtimestamp
1 parent 0c0a144 commit 6294fc7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/email/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ def formatdate(timeval=None, localtime=False, usegmt=False):
143143
# 2822 requires that day and month names be the English abbreviations.
144144
if timeval is None:
145145
timeval = time.time()
146-
if localtime or usegmt:
147-
dt = datetime.datetime.fromtimestamp(timeval, datetime.timezone.utc)
148-
else:
149-
dt = datetime.datetime.utcfromtimestamp(timeval)
146+
dt = datetime.datetime.fromtimestamp(timeval, datetime.timezone.utc)
147+
150148
if localtime:
151149
dt = dt.astimezone()
152150
usegmt = False
151+
elif not usegmt:
152+
dt = dt.replace(tzinfo=None)
153153
return format_datetime(dt, usegmt)
154154

155155
def format_datetime(dt, usegmt=False):

Lib/test/test_plistlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ def test_large_timestamp(self):
925925
# Issue #26709: 32-bit timestamp out of range
926926
for ts in -2**31-1, 2**31:
927927
with self.subTest(ts=ts):
928-
d = (datetime.datetime.utcfromtimestamp(0) +
928+
d = (datetime.datetime(1970, 1, 1, 0, 0) +
929929
datetime.timedelta(seconds=ts))
930930
data = plistlib.dumps(d, fmt=plistlib.FMT_BINARY)
931931
self.assertEqual(plistlib.loads(data), d)

0 commit comments

Comments
 (0)
0