arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.63k stars 669 forks source link

datetime.utcnow is deprecated #1178

Open guruofgentoo opened 1 week ago

guruofgentoo commented 1 week ago

Python 3.12 deprecates the use of datetime.datetime.utcnow, suggesting instead to use datetime.datetime.now(datetime.UTC).

Example from the humanize method:

  File "/root/project/my_project/libs/utils.py", line 54, in arrow_humanize
    return time.humanize()
           ^^^^^^^^^^^^^^^
  File "/root/project/.tox/py312/lib/python3.12/site-packages/arrow/arrow.py", line 1150, in humanize
    utc = dt_datetime.utcnow().replace(tzinfo=dateutil_tz.tzutc())
          ^^^^^^^^^^^^^^^^^^^^
DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).