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).
--
Ticket URL: <https://code.djangoproject.com/ticket/32366>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Carlton Gibson
Comment:
[https://github.com/django/django/pull/13916 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:3>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:4>
* owner: Carlton Gibson => Nick Pope
* needs_better_patch: 1 => 0
Comment:
I've created a new [https://github.com/django/django/pull/14374 PR] to try
and get this completed.
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d06c5b358149c02a62da8a5469264d05f29ac659" d06c5b3]:
{{{
#!CommitTicketReference repository=""
revision="d06c5b358149c02a62da8a5469264d05f29ac659"
Fixed #32366 -- Updated datetime module usage to recommended approach.
- Replaced datetime.utcnow() with datetime.now().
- Replaced datetime.utcfromtimestamp() with datetime.fromtimestamp().
- Replaced datetime.utctimetuple() with datetime.timetuple().
- Replaced calendar.timegm() and datetime.utctimetuple() with
datetime.timestamp().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:8>
Comment (by Carlton Gibson <carlton.gibson@…>):
In [changeset:"69ffb1acf38bd34f76707468bb592eb4b164e2da" 69ffb1ac]:
{{{
#!CommitTicketReference repository=""
revision="69ffb1acf38bd34f76707468bb592eb4b164e2da"
Refs #32366 -- Avoided use of datetime.utcnow() in the documentation.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:7>
Comment (by Carlton Gibson <carlton.gibson@…>):
In [changeset:"cd84f7acfa65775837952bf4d1b654966be3c2cf" cd84f7ac]:
{{{
#!CommitTicketReference repository=""
revision="cd84f7acfa65775837952bf4d1b654966be3c2cf"
[3.2.x] Refs #32366 -- Avoided use of datetime.utcnow() in the
documentation.
Backport of 69ffb1acf38bd34f76707468bb592eb4b164e2da from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32366#comment:9>