mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
GH-103857: Deprecate utcnow and utcfromtimestamp (#103858)
Using `datetime.datetime.utcnow()` and `datetime.datetime.utcfromtimestamp()` will now raise a `DeprecationWarning`. We also have removed our internal uses of these functions and documented the change.
This commit is contained in:
parent
a5308e188b
commit
0b7fd8ffc5
10 changed files with 101 additions and 34 deletions
|
|
@ -896,6 +896,10 @@ Other constructors, all class methods:
|
|||
in UTC. As such, the recommended way to create an object representing the
|
||||
current time in UTC is by calling ``datetime.now(timezone.utc)``.
|
||||
|
||||
.. deprecated:: 3.12
|
||||
|
||||
Use :meth:`datetime.now` with :attr:`UTC` instead.
|
||||
|
||||
|
||||
.. classmethod:: datetime.fromtimestamp(timestamp, tz=None)
|
||||
|
||||
|
|
@ -964,6 +968,10 @@ Other constructors, all class methods:
|
|||
:c:func:`gmtime` function. Raise :exc:`OSError` instead of
|
||||
:exc:`ValueError` on :c:func:`gmtime` failure.
|
||||
|
||||
.. deprecated:: 3.12
|
||||
|
||||
Use :meth:`datetime.fromtimestamp` with :attr:`UTC` instead.
|
||||
|
||||
|
||||
.. classmethod:: datetime.fromordinal(ordinal)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue