Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

not sure, I tried this in Python 3.11.6 and `datetime.UTC` works whereas `datetime.timezone.utc` doesn't exist

in any case, just compare

    datetime.datetime.utcnow()
and

      datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
verbosity is not a virtue in this case


`datetime.timezone.utc` is the original way of doing it and should work just fine on a stock Python 3.11 install. `datetime.UTC` is a relatively recent addition, and if you look at the actual type of the object it returns, it's still `datetime.timezone.utc`


So my installation was outdated. Still not fan of having two different ways to refer to the same thing.


This is verbose because it is dissuaded. The whole point of this change is to not have users get naive datetime objects, of course it gets more verbose.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: