8000 GH-103857: Deprecate utcnow and utcfromtimestamp by pganssle · Pull Request #103858 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-103857: Deprecate utcnow and utcfromtimestamp #103858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove all internal uses of utcfromtimestamp
  • Loading branch information
pganssle committed Apr 27, 2023
commit 97eff7f5c6a8a9127454d242defd0bc856a03e02
8 changes: 4 additions & 4 deletions Lib/email/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def formatdate(timeval=None, localtime=False, usegmt=False):
# 2822 requires that day and month names be the English abbreviations.
if timeval is None:
timeval = time.time()
if localtime or usegmt:
dt = datetime.datetime.fromtimestamp(timeval, datetime.timezone.utc)
else:
dt = datetime.datetime.utcfromtimestamp(timeval)
dt = datetime.datetime.fromtimestamp(timeval, datetime.timezone.utc)

if localtime:
dt = dt.astimezone()
usegmt = False
elif not usegmt:
dt = dt.replace(tzinfo=None)
return format_datetime(dt, usegmt)

def format_datetime(dt, usegmt=False):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_plistlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def test_large_timestamp(self):
# Issue #26709: 32-bit timestamp out of range
for ts in -2**31-1, 2**31:
with self.subTest(ts=ts):
d = (datetime.datetime.utcfromtimestamp(0) +
d = (datetime.datetime(1970, 1, 1, 0, 0) +
datetime.timedelta(seconds=ts))
data = plistlib.dumps(d, fmt=plistlib.FMT_BINARY)
self.assertEqual(plistlib.loads(data), d)
Expand Down
0