#32366 closed Cleanup/optimization (fixed)
Update usage of now() & co
Reported by: | Carlton Gibson | Owned by: | Nick Pope |
---|---|---|---|
Component: | Utilities | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using datetime.now(), rather than utcnow() is the modern recommended approach.
Warning in docs:
... the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc).
https://docs.python.org/3.9/library/datetime.html#datetime.datetime.now
https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
More depth here:
https://blog.ganssle.io/articles/2019/11/utcnow.html
datetime.utcfromtimestamp()
and datetime.utctimetuple()
carry similar warnings.
- Update the code to modern usage.
- Update docs examples (for backport to stable docs).
Change History (9)
comment:1 by , 4 years ago
Owner: | changed from | to
---|
comment:2 by , 4 years ago
Summary: | Update usage of now() &co → Update usage of now() & co |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 4 years ago
Has patch: | set |
---|
comment:4 by , 4 years ago
Patch needs improvement: | set |
---|
comment:5 by , 4 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | unset |
I've created a new PR to try and get this completed.
comment:6 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR