Codemod to add tz=UTC
to any datetime
function without a timezone
#385
Labels
new-codemod
Description for a new codemod
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.The text was updated successfully, but these errors were encountered: