I'm still annoyed that they are deprecating datetime.datetime.utcnow(). I have over 1000 references to that function in my projects folder. I understand the footguns that naive datetimes present to the unwary, and yet I still prefer to work with naive always-UTC datetimes. Alas I will end up doing some kind of crazy find-and-replace (at least in the Python 3 code) to something like `datetime.datetime.now(tz=datetime.…
import datetime
class my_datetime(datetime.datetime):
@staticmethod
def utcnow():
return datetime.datetime.now(tz=datetime.timezone.utc).replace(tzinfo=None)
datetime.datetime = my_datetime
And then in your codebase make sure you import my_patches whenever you use datetime. E.g.: import my_patches
import datetime
print(datetime.datetime.utcnow())