You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codemod to add tz=UTC to any datetime function without a timezone #385
A while ago I discovered this flake8 datetime plugin which if installed warns you if you use something like datetime.datetime() (and others in the page). As is, the timezone used is whatever timezone the machine that runs the code is using. This may be okay in some cases, but it can lead to bugs. And misinterpretation of dates have been the culprit for serious issues in banking, satellites, Y2K fiasco, etc. So this is really important.
My suggestion for this codemod is to add a tz=UTC parameter to force code to run in UTC time. The big downside here is if the machine that ran the code previously was using a different timezone, crashes or bugs can happen on the first run. But the big advantage here is that it will force developers to think about which timezone they need.
Activity
drdavella commentedon Mar 19, 2024
@clavedeluna this is an interesting idea. I wonder whether this overlaps at all with #368?
clavedeluna commentedon May 6, 2024
Also add the sonar rule as a sonar codemo
https://rules.sonarsource.com/python/RSPEC-6903/
clavedeluna commentedon May 6, 2024
I made quite a bit of progress in this branch but due to other work needs I'm going to unassign this for now.
clavedeluna commentedon Aug 19, 2024
After completing [https://github.com//pull/802]) we should add all remaining functions listed in the flake8 plugin