diff --git a/Lib/datetime.py b/Lib/datetime.py index 260b1de38877a6..779851f5b2aa9c 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1682,13 +1682,13 @@ def fromtimestamp(cls, t, tz=None): @classmethod def utcfromtimestamp(cls, t): """Construct a naive UTC datetime from a POSIX timestamp.""" - return cls._fromtimestamp(t, True, None) + return cls._fromtimestamp(t, True, timezone.utc) @classmethod def now(cls, tz=None): "Construct a datetime from time.time() and optional time zone info." t = _time.time() - return cls.fromtimestamp(t, tz) + return cls.fromtimestamp(t, tz).astimezone() @classmethod def utcnow(cls): diff --git a/Misc/NEWS.d/next/Library/2022-04-19-22-38-45.gh-issue-88829.a0Dicd.rst b/Misc/NEWS.d/next/Library/2022-04-19-22-38-45.gh-issue-88829.a0Dicd.rst new file mode 100644 index 00000000000000..4a34c844d7eba6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-19-22-38-45.gh-issue-88829.a0Dicd.rst @@ -0,0 +1 @@ +now() and utcnow() returns timezone-aware objects