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

Python 3.12 datetime.utcnow() deprecation #264

Closed
aaronwmorris opened this issue Oct 15, 2023 · 2 comments
Closed

Python 3.12 datetime.utcnow() deprecation #264

aaronwmorris opened this issue Oct 15, 2023 · 2 comments

Comments

@aaronwmorris
Copy link

With the deprecation of datetime.utcnow(), what is the proper way of passing dates to pyephem?

https://github.com/brandon-rhodes/pyephem/blob/master/ephem/doc/date.rst still shows the utcnow() method. Python's suggested code is to use datetime.now(timezone.utc) but this produces a timezone aware object where utcnow() produces a timezone naive object. Will the timezone aware object cause any problems with pyephem?

@brandon-rhodes
Copy link
Owner

With the deprecation of datetime.utcnow(), what is the proper way of passing dates to pyephem?

Unless Python removes utcnow() entirely, my guess is that I keep the documentation as it is now. The advice to use utcnow() was added to the docs in 2015 and I don't recall having many user problems as a result? So unless it starts causing new problems for people, I think the advice will be kept the same.

Will the timezone aware object cause any problems with pyephem?

Happily, they are fully supported — check out the documentation here for an example:

https://rhodesmill.org/pyephem/quick.html#from-a-specific-timezone

@aaronwmorris
Copy link
Author

aaronwmorris commented Nov 23, 2023

The release notes for Python 3.12 indicate utcnow() will be removed from a future release (it does not mention a specific release like some of the other deprecations). Using utcnow in Python 3.12 results in a deprecation warning.

Quoted from https://docs.python.org/3/whatsnew/3.12.html

datetime: 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.)

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

No branches or pull requests

2 participants