3.12: Replace deprecated `utcnow()` with `now(utc)`
There are two deprecation warnings showing up on Python 3.12 beta, for example:
tests/test_tablib.py: 54 warnings
/home/runner/work/tablib/tablib/.tox/py/lib/python3.12/site-packages/openpyxl/packaging/core.py:99: DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC).
now = datetime.datetime.utcnow()
tests/test_tablib.py: 17 warnings
/home/runner/work/tablib/tablib/.tox/py/lib/python3.12/site-packages/openpyxl/writer/excel.py:292: DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC).
workbook.properties.modified = datetime.datetime.utcnow()
https://github.com/hugovk/tablib/actions/runs/5212546690/jobs/9406282736#step:5:106
Docs:
- https://docs.python.org/3.12/whatsnew/3.12.html#deprecated
- https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcnow
To fix, replace:
-datetime.datetime.utcnow()
+datetime.datetime.now(datetime.timezone.utc)
In openpyxl/packaging/core.py
and openpyxl/writer/excel.py
.