Skip to content

Commit

Permalink
Fix deprecation in Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Dec 3, 2023
2 parents 4f44963 + 00f62ce commit cbcc59f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions freezegun/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def today(cls):

@classmethod
def utcnow(cls):
result = cls._time_to_freeze() or real_datetime.utcnow()
result = cls._time_to_freeze() or real_datetime.now(datetime.timezone.utc)
return datetime_to_fakedatetime(result)

@staticmethod
Expand Down Expand Up @@ -463,14 +463,14 @@ def _parse_time_to_freeze(time_to_freeze_str):
:returns: a naive ``datetime.datetime`` object
"""
if time_to_freeze_str is None:
time_to_freeze_str = datetime.datetime.utcnow()
time_to_freeze_str = datetime.datetime.now(datetime.timezone.utc)

if isinstance(time_to_freeze_str, datetime.datetime):
time_to_freeze = time_to_freeze_str
elif isinstance(time_to_freeze_str, datetime.date):
time_to_freeze = datetime.datetime.combine(time_to_freeze_str, datetime.time())
elif isinstance(time_to_freeze_str, datetime.timedelta):
time_to_freeze = datetime.datetime.utcnow() + time_to_freeze_str
time_to_freeze = datetime.datetime.now(datetime.timezone.utc) + time_to_freeze_str
else:
time_to_freeze = parser.parse(time_to_freeze_str)

Expand Down

0 comments on commit cbcc59f

Please # to comment.