Hi all. Perhaps it’s my brain getting old, but I always forget if datetime.now() and utcnow() return a naive or aware datetime object (it’s naive), and how to get the actual aware version. I’m not proposing any new improved way of handling timezones or anything like that: I’m just proposing aliases with hopefully very clear names that make it obvious what they do, and what the counterpart is called. Specifically, I propose adding the following class methods to datetime.datetime:
localnow_naive() as an alias to now()
localnow_aware() as an alias to now().astimezone()
utcnow_naive() as an alias to utcnow()
utcnow_aware() as an alias to now(timezone.utc)
I actually have a pull request open for this, but I need some feedback. Here’s the PR:
I’d be sympathetic to that, in fact I was considering suggesting it as part of this, I just thought I had better chance of getting agreement if I don’t mix in a proposal as controversial (I assume) as deprecating a widely used method.