dateutil
dateutil copied to clipboard
utcfromtimestamp deprecated
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)
Same here. My stack has three libraries that depend on dateutil. A minor release addressing this would be very welcome
See #1314
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.
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?
@rosteen see https://github.com/dateutil/dateutil/pull/1130#issuecomment-1808635487
@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).