diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1363a40..c6afce8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,10 @@ Changelog ========= +* Fix ``utcfromtimestamp()`` warning on Python 3.12+. + + Thanks to Konstantin Baikov in `PR #424 `__. + * Avoid calling deprecated ``uuid._load_system_functions()`` on Python 3.9+. Thanks to Nikita Sobolev for the ping in `CPython Issue #113308 `__. diff --git a/src/time_machine/__init__.py b/src/time_machine/__init__.py index 4a6acd8..ee366f8 100644 --- a/src/time_machine/__init__.py +++ b/src/time_machine/__init__.py @@ -350,7 +350,7 @@ def utcnow() -> dt.datetime: if not coordinates_stack: result: dt.datetime = _time_machine.original_utcnow() return result - return dt.datetime.utcfromtimestamp(time()) + return dt.datetime.fromtimestamp(time(), dt.timezone.utc).replace(tzinfo=None) # time module