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

utcfromtimestamp deprecated #1340

Closed
DanielJOHara opened this issue Feb 13, 2024 · 6 comments
Closed

utcfromtimestamp deprecated #1340

DanielJOHara opened this issue Feb 13, 2024 · 6 comments

Comments

@DanielJOHara
Copy link

My project generated a deprecated function warning for utcfromtimestamp.

EPOCH = datetime.datetime.utcfromtimestamp(0)

This blog suggest a replacement https://blog.ganssle.io/articles/2019/11/utcnow.html
EPOCH = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)

@bwalsh
Copy link

bwalsh commented Feb 15, 2024

Same here. My stack has three libraries that depend on dateutil. A minor release addressing this would be very welcome

@troyswanson
Copy link

See #1314

@FObersteiner
Copy link

The original code using utcfromtimestamp gives a naive datetime; the "correct" way to get this without triggering the deprecation warning would be

EPOCH = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc).replace(tzinfo=None)

I'm neither familiar with dateutil's codebase nor do I think this is elegant - but, if you know what you're doing, it is OK I think.

@rosteen
Copy link

rosteen commented Feb 29, 2024

It looks like this was fixed in #1285, but the last release of this package was in 2021. There have been a bunch of PRs merged since then, I wonder if there is a plan to do another release at some point to get those fixes out the door?

@edgarrmondragon
Copy link

@rosteen see #1130 (comment)

@rosteen
Copy link

rosteen commented Feb 29, 2024

@rosteen see #1130 (comment)

Thanks, I dug in and saw all the discussion of that after I commented (I missed that the comment above was linking to release discussion).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants