Skip to content

Commit

Permalink
Fix utcfromtimestamp() deprecation warning (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbaikov authored Mar 1, 2024
1 parent 2eda5ad commit 46c66af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog
=========

* Fix ``utcfromtimestamp()`` warning on Python 3.12+.

Thanks to Konstantin Baikov in `PR #424 <https://github.com/adamchainz/time-machine/pull/424>`__.

* Avoid calling deprecated ``uuid._load_system_functions()`` on Python 3.9+.

Thanks to Nikita Sobolev for the ping in `CPython Issue #113308 <https://github.com/python/cpython/issues/113308>`__.
Expand Down
2 changes: 1 addition & 1 deletion src/time_machine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46c66af

Please sign in to comment.