From 5787f6d603fc94a73f37c41ef765103292cfd622 Mon Sep 17 00:00:00 2001 From: stijn Date: Mon, 17 Apr 2023 09:48:22 +0200 Subject: [PATCH] datetime: Make datetime.now() work by defaulting to UTC --- python-stdlib/datetime/datetime.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python-stdlib/datetime/datetime.py b/python-stdlib/datetime/datetime.py index 0f2a89105..666ff823d 100644 --- a/python-stdlib/datetime/datetime.py +++ b/python-stdlib/datetime/datetime.py @@ -633,10 +633,9 @@ def fromtimestamp(cls, ts, tz=None): else: us = 0 if tz is None: - raise NotImplementedError - else: - dt = cls(*_tmod.gmtime(ts)[:6], microsecond=us, tzinfo=tz) - dt = tz.fromutc(dt) + tz = timezone.utc + dt = cls(*_tmod.gmtime(ts)[:6], microsecond=us, tzinfo=tz) + dt = tz.fromutc(dt) return dt @classmethod