timvink / mkdocs-git-revision-date-localized-plugin

MkDocs plugin to add a last updated date to your site pages
https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html
MIT License
193 stars 39 forks source link

DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version #121

Closed natakazakova closed 10 months ago

natakazakova commented 10 months ago

Hi! Can you please update the usage of utcfromtimestamp? I have about 70+ info warnings in my logs. It became difficult to search warnings and errors in log.

DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  File "/usr/local/lib/python3.12/site-packages/mkdocs_git_revision_date_localized_plugin/util.py", line 204, in get_date_formats_for_timestamp
    date_formats = self._date_formats(
  File "/usr/local/lib/python3.12/site-packages/mkdocs_git_revision_date_localized_plugin/util.py", line 66, in _date_formats
    utc_revision_date = datetime.utcfromtimestamp(int(unix_timestamp))
timvink commented 10 months ago

Python 3.12 is not officially supported yet, but it would be an improvement.

datetime.datetime’s utcnow() and utcfromtimestamp() are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, call now() and fromtimestamp() with the tz parameter set to datetime.UTC. (Contributed by Paul Ganssle in gh-103857.)