Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid usage of deprecated datetime.datetime.utcfromtimestamp in pendulum.from_timestamp #803

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Taragolis
Copy link

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

datetime.datetime.utcfromtimestamp() is deprecated into the Python 3.12 as result current implementation raise warning message

/usr/local/lib/python3.12/site-packages/pendulum/__init__.py:295 DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC:

Copy link

codspeed-hq bot commented Feb 16, 2024

CodSpeed Performance Report

Merging #803 will not alter performance

Comparing Taragolis:remove-deprecated-from-python-stdlib (aac69cc) with master (3e3fec6)

Summary

✅ 1 untouched benchmarks

iakat added a commit to iakat/ircstates that referenced this pull request Mar 13, 2024
@natikgadzhi natikgadzhi mentioned this pull request Jun 1, 2024
2 tasks
dt = datetime(
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond
)
dt = DateTime.fromtimestamp(timestamp, tz=UTC)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current suggestion is recursive and does not use the correct keyword:

Suggested change
dt = DateTime.fromtimestamp(timestamp, tz=UTC)
dt = _datetime.datetime.fromtimestamp(timestamp, tzinfo=UTC)

For the develop branch, the change must be done in pendulum/pendulum.py:491

dt = datetime.datetime.utcfromtimestamp(timestamp).replace(tzinfo=UTC)

to

dt = datetime.datetime.fromtimestamp(timestamp, tzinfo=UTC)

iakat added a commit to iakat/ircstates that referenced this pull request Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants