-
Notifications
You must be signed in to change notification settings - Fork 295
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
Replacement of deprecated datetime.datetime.utcnow()
#2752
Comments
The third option seems like the most sensible, if work-intensive, option. I can imagine the first two options causing potential unexpected issues for users with stange setups etc. |
Agree that option three is the best alternative here. I remember now why I used option three in the ninjogeotiff writer: I was blissfully unaware of satpy/satpy/writers/ninjogeotiff.py Line 401 in 2c27b35
It could affect (monitoring) tools that interpret logfiles. It could also change the format in which the CF writer writes timestamps. |
The log formatting can be tuned by the user if necessary. I this mostly affects Trollflow2 and the collectors.
This shouldn't change for the users, we (the devs) should take care of maintaining that. |
I also prefer option 3. |
One complication with option 3: |
Feature Request
As of Python 3.12 the usage of
datetime.datetime.utcnow()
and.utcfromtimestamp()
are deprecated and will be removed in a later version. We need to address this in Satpy (and in all the other Pytroll packages).Describe the solution you'd like
There are some options I can think of:
.now()
returing time their computer is set toos.environ["TZ"]; time.tzset()
)dt.datetime.now(dt.datetime.timezone.utc)
The first option is problematic in many ways if the computer is not in UTC, one of which is the unpredictability of the tests. Forcing local time to UTC might cause weird problems if the user wants to use real local time for some part of the processing.
So we have the third option and make all the datetimes in Satpy (and Pytroll in general) timezone-aware. This was the option we kind of agreed in the last Pytroll monthly meeting, but the attendance was pretty limited. It'll require some (lots of?) work to make sure all the datetime stuff still work as intended.
Describe any changes to existing user workflow
Depends on the option. With the third option should only affect developers.
Additional context
Some links that discuss the deprecation:
utcnow
andutcfromtimestamp
python/cpython#103857 (see also the linked https://blog.ganssle.io/articles/2019/11/utcnow.html)Ping: @djhoese @mraspaud @gerritholl @simonrp84 @ameraner @sfinkens
The text was updated successfully, but these errors were encountered: