[3.12] gh-101100: Fix datetime reference warnings (GH-114661) (GH-114716)

(cherry picked from commit e8b8f5e9c2)

Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-01-29 16:12:03 +01:00 committed by GitHub
parent 0795d9a17a
commit 783339a086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 58 additions and 54 deletions

View file

@ -83,20 +83,25 @@ if venvdir is not None:
nitpick_ignore = [ nitpick_ignore = [
# Standard C functions # Standard C functions
('c:func', 'calloc'), ('c:func', 'calloc'),
('c:func', 'ctime'),
('c:func', 'dlopen'), ('c:func', 'dlopen'),
('c:func', 'exec'), ('c:func', 'exec'),
('c:func', 'fcntl'), ('c:func', 'fcntl'),
('c:func', 'fork'), ('c:func', 'fork'),
('c:func', 'free'), ('c:func', 'free'),
('c:func', 'gettimeofday'),
('c:func', 'gmtime'), ('c:func', 'gmtime'),
('c:func', 'localeconv'),
('c:func', 'localtime'), ('c:func', 'localtime'),
('c:func', 'main'), ('c:func', 'main'),
('c:func', 'malloc'), ('c:func', 'malloc'),
('c:func', 'mktime'),
('c:func', 'printf'), ('c:func', 'printf'),
('c:func', 'realloc'), ('c:func', 'realloc'),
('c:func', 'snprintf'), ('c:func', 'snprintf'),
('c:func', 'sprintf'), ('c:func', 'sprintf'),
('c:func', 'stat'), ('c:func', 'stat'),
('c:func', 'strftime'),
('c:func', 'system'), ('c:func', 'system'),
('c:func', 'time'), ('c:func', 'time'),
('c:func', 'vsnprintf'), ('c:func', 'vsnprintf'),

View file

@ -14,7 +14,7 @@
.. XXX what order should the types be discussed in? .. XXX what order should the types be discussed in?
The :mod:`datetime` module supplies classes for manipulating dates and times. The :mod:`!datetime` module supplies classes for manipulating dates and times.
While date and time arithmetic is supported, the focus of the implementation is While date and time arithmetic is supported, the focus of the implementation is
on efficient attribute extraction for output formatting and manipulation. on efficient attribute extraction for output formatting and manipulation.
@ -70,7 +70,7 @@ These :class:`tzinfo` objects capture information about the offset from UTC
time, the time zone name, and whether daylight saving time is in effect. time, the time zone name, and whether daylight saving time is in effect.
Only one concrete :class:`tzinfo` class, the :class:`timezone` class, is Only one concrete :class:`tzinfo` class, the :class:`timezone` class, is
supplied by the :mod:`datetime` module. The :class:`timezone` class can supplied by the :mod:`!datetime` module. The :class:`timezone` class can
represent simple timezones with fixed offsets from UTC, such as UTC itself or represent simple timezones with fixed offsets from UTC, such as UTC itself or
North American EST and EDT timezones. Supporting timezones at deeper levels of North American EST and EDT timezones. Supporting timezones at deeper levels of
detail is up to the application. The rules for time adjustment across the detail is up to the application. The rules for time adjustment across the
@ -80,7 +80,7 @@ standard suitable for every application aside from UTC.
Constants Constants
--------- ---------
The :mod:`datetime` module exports the following constants: The :mod:`!datetime` module exports the following constants:
.. data:: MINYEAR .. data:: MINYEAR
@ -631,7 +631,7 @@ Notes:
date2.toordinal()``. Date comparison raises :exc:`TypeError` if date2.toordinal()``. Date comparison raises :exc:`TypeError` if
the other comparand isn't also a :class:`date` object. However, the other comparand isn't also a :class:`date` object. However,
``NotImplemented`` is returned instead if the other comparand has a ``NotImplemented`` is returned instead if the other comparand has a
:meth:`timetuple` attribute. This hook gives other kinds of date objects a :attr:`~date.timetuple` attribute. This hook gives other kinds of date objects a
chance at implementing mixed-type comparison. If not, when a :class:`date` chance at implementing mixed-type comparison. If not, when a :class:`date`
object is compared to an object of a different type, :exc:`TypeError` is raised object is compared to an object of a different type, :exc:`TypeError` is raised
unless the comparison is ``==`` or ``!=``. The latter cases return unless the comparison is ``==`` or ``!=``. The latter cases return
@ -1212,7 +1212,7 @@ Supported operations:
object addresses, datetime comparison normally raises :exc:`TypeError` if the object addresses, datetime comparison normally raises :exc:`TypeError` if the
other comparand isn't also a :class:`.datetime` object. However, other comparand isn't also a :class:`.datetime` object. However,
``NotImplemented`` is returned instead if the other comparand has a ``NotImplemented`` is returned instead if the other comparand has a
:meth:`timetuple` attribute. This hook gives other kinds of date objects a :attr:`~.datetime.timetuple` attribute. This hook gives other kinds of date objects a
chance at implementing mixed-type comparison. If not, when a :class:`.datetime` chance at implementing mixed-type comparison. If not, when a :class:`.datetime`
object is compared to an object of a different type, :exc:`TypeError` is raised object is compared to an object of a different type, :exc:`TypeError` is raised
unless the comparison is ``==`` or ``!=``. The latter cases return unless the comparison is ``==`` or ``!=``. The latter cases return
@ -1341,22 +1341,22 @@ Instance methods:
where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1``
is the day number within the current year starting with ``1`` for January is the day number within the current year starting with ``1`` for January
1st. The :attr:`tm_isdst` flag of the result is set according to the 1st. The :attr:`~time.struct_time.tm_isdst` flag of the result is set according to the
:meth:`dst` method: :attr:`.tzinfo` is ``None`` or :meth:`dst` returns :meth:`dst` method: :attr:`.tzinfo` is ``None`` or :meth:`dst` returns
``None``, :attr:`tm_isdst` is set to ``-1``; else if :meth:`dst` returns a ``None``, :attr:`!tm_isdst` is set to ``-1``; else if :meth:`dst` returns a
non-zero value, :attr:`tm_isdst` is set to ``1``; else :attr:`tm_isdst` is non-zero value, :attr:`!tm_isdst` is set to ``1``; else :attr:`!tm_isdst` is
set to ``0``. set to ``0``.
.. method:: datetime.utctimetuple() .. method:: datetime.utctimetuple()
If :class:`.datetime` instance *d* is naive, this is the same as If :class:`.datetime` instance *d* is naive, this is the same as
``d.timetuple()`` except that :attr:`tm_isdst` is forced to 0 regardless of what ``d.timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced to 0 regardless of what
``d.dst()`` returns. DST is never in effect for a UTC time. ``d.dst()`` returns. DST is never in effect for a UTC time.
If *d* is aware, *d* is normalized to UTC time, by subtracting If *d* is aware, *d* is normalized to UTC time, by subtracting
``d.utcoffset()``, and a :class:`time.struct_time` for the ``d.utcoffset()``, and a :class:`time.struct_time` for the
normalized time is returned. :attr:`tm_isdst` is forced to 0. Note normalized time is returned. :attr:`!tm_isdst` is forced to 0. Note
that an :exc:`OverflowError` may be raised if *d*.year was that an :exc:`OverflowError` may be raised if *d*.year was
``MINYEAR`` or ``MAXYEAR`` and UTC adjustment spills over a year ``MINYEAR`` or ``MAXYEAR`` and UTC adjustment spills over a year
boundary. boundary.
@ -1544,7 +1544,7 @@ Instance methods:
Examples of Usage: :class:`.datetime` Examples of Usage: :class:`.datetime`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Examples of working with :class:`~datetime.datetime` objects: Examples of working with :class:`.datetime` objects:
.. doctest:: .. doctest::
@ -1755,9 +1755,9 @@ is aware, :exc:`TypeError` is raised if an order comparison is attempted. For eq
comparisons, naive instances are never equal to aware instances. comparisons, naive instances are never equal to aware instances.
If both comparands are aware, and have If both comparands are aware, and have
the same :attr:`~time.tzinfo` attribute, the common :attr:`~time.tzinfo` attribute is the same :attr:`~.time.tzinfo` attribute, the common :attr:`!tzinfo` attribute is
ignored and the base times are compared. If both comparands are aware and ignored and the base times are compared. If both comparands are aware and
have different :attr:`~time.tzinfo` attributes, the comparands are first adjusted by have different :attr:`!tzinfo` attributes, the comparands are first adjusted by
subtracting their UTC offsets (obtained from ``self.utcoffset()``). In order subtracting their UTC offsets (obtained from ``self.utcoffset()``). In order
to stop mixed-type comparisons from falling back to the default comparison by to stop mixed-type comparisons from falling back to the default comparison by
object address, when a :class:`.time` object is compared to an object of a object address, when a :class:`.time` object is compared to an object of a
@ -1765,7 +1765,7 @@ different type, :exc:`TypeError` is raised unless the comparison is ``==`` or
``!=``. The latter cases return :const:`False` or :const:`True`, respectively. ``!=``. The latter cases return :const:`False` or :const:`True`, respectively.
.. versionchanged:: 3.3 .. versionchanged:: 3.3
Equality comparisons between aware and naive :class:`~datetime.time` instances Equality comparisons between aware and naive :class:`.time` instances
don't raise :exc:`TypeError`. don't raise :exc:`TypeError`.
In Boolean contexts, a :class:`.time` object is always considered to be true. In Boolean contexts, a :class:`.time` object is always considered to be true.
@ -1972,7 +1972,7 @@ Examples of working with a :class:`.time` object::
You need to derive a concrete subclass, and (at least) You need to derive a concrete subclass, and (at least)
supply implementations of the standard :class:`tzinfo` methods needed by the supply implementations of the standard :class:`tzinfo` methods needed by the
:class:`.datetime` methods you use. The :mod:`datetime` module provides :class:`.datetime` methods you use. The :mod:`!datetime` module provides
:class:`timezone`, a simple concrete subclass of :class:`tzinfo` which can :class:`timezone`, a simple concrete subclass of :class:`tzinfo` which can
represent timezones with fixed offset from UTC such as UTC itself or North represent timezones with fixed offset from UTC such as UTC itself or North
American EST and EDT. American EST and EDT.
@ -1985,7 +1985,7 @@ Examples of working with a :class:`.time` object::
A concrete subclass of :class:`tzinfo` may need to implement the following A concrete subclass of :class:`tzinfo` may need to implement the following
methods. Exactly which methods are needed depends on the uses made of aware methods. Exactly which methods are needed depends on the uses made of aware
:mod:`datetime` objects. If in doubt, simply implement all of them. :mod:`!datetime` objects. If in doubt, simply implement all of them.
.. method:: tzinfo.utcoffset(dt) .. method:: tzinfo.utcoffset(dt)
@ -2026,7 +2026,7 @@ Examples of working with a :class:`.time` object::
already been added to the UTC offset returned by :meth:`utcoffset`, so there's already been added to the UTC offset returned by :meth:`utcoffset`, so there's
no need to consult :meth:`dst` unless you're interested in obtaining DST info no need to consult :meth:`dst` unless you're interested in obtaining DST info
separately. For example, :meth:`datetime.timetuple` calls its :attr:`~.datetime.tzinfo` separately. For example, :meth:`datetime.timetuple` calls its :attr:`~.datetime.tzinfo`
attribute's :meth:`dst` method to determine how the :attr:`tm_isdst` flag attribute's :meth:`dst` method to determine how the :attr:`~time.struct_time.tm_isdst` flag
should be set, and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for should be set, and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for
DST changes when crossing time zones. DST changes when crossing time zones.
@ -2042,7 +2042,7 @@ Examples of working with a :class:`.time` object::
relies on this, but cannot detect violations; it's the programmer's relies on this, but cannot detect violations; it's the programmer's
responsibility to ensure it. If a :class:`tzinfo` subclass cannot guarantee responsibility to ensure it. If a :class:`tzinfo` subclass cannot guarantee
this, it may be able to override the default implementation of this, it may be able to override the default implementation of
:meth:`tzinfo.fromutc` to work correctly with :meth:`astimezone` regardless. :meth:`tzinfo.fromutc` to work correctly with :meth:`~.datetime.astimezone` regardless.
Most implementations of :meth:`dst` will probably look like one of these two:: Most implementations of :meth:`dst` will probably look like one of these two::
@ -2071,7 +2071,7 @@ Examples of working with a :class:`.time` object::
.. method:: tzinfo.tzname(dt) .. method:: tzinfo.tzname(dt)
Return the time zone name corresponding to the :class:`.datetime` object *dt*, as Return the time zone name corresponding to the :class:`.datetime` object *dt*, as
a string. Nothing about string names is defined by the :mod:`datetime` module, a string. Nothing about string names is defined by the :mod:`!datetime` module,
and there's no requirement that it mean anything in particular. For example, and there's no requirement that it mean anything in particular. For example,
"GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all "GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all
valid replies. Return ``None`` if a string name isn't known. Note that this is valid replies. Return ``None`` if a string name isn't known. Note that this is
@ -2119,7 +2119,7 @@ There is one more :class:`tzinfo` method that a subclass may wish to override:
different years. An example of a time zone the default :meth:`fromutc` different years. An example of a time zone the default :meth:`fromutc`
implementation may not handle correctly in all cases is one where the standard implementation may not handle correctly in all cases is one where the standard
offset (from UTC) depends on the specific date and time passed, which can happen offset (from UTC) depends on the specific date and time passed, which can happen
for political reasons. The default implementations of :meth:`astimezone` and for political reasons. The default implementations of :meth:`~.datetime.astimezone` and
:meth:`fromutc` may not produce the result you want if the result is one of the :meth:`fromutc` may not produce the result you want if the result is one of the
hours straddling the moment the standard offset changes. hours straddling the moment the standard offset changes.
@ -2185,10 +2185,10 @@ hour that can't be spelled unambiguously in local wall time: the last hour of
daylight time. In Eastern, that's times of the form 5:MM UTC on the day daylight time. In Eastern, that's times of the form 5:MM UTC on the day
daylight time ends. The local wall clock leaps from 1:59 (daylight time) back daylight time ends. The local wall clock leaps from 1:59 (daylight time) back
to 1:00 (standard time) again. Local times of the form 1:MM are ambiguous. to 1:00 (standard time) again. Local times of the form 1:MM are ambiguous.
:meth:`astimezone` mimics the local clock's behavior by mapping two adjacent UTC :meth:`~.datetime.astimezone` mimics the local clock's behavior by mapping two adjacent UTC
hours into the same local hour then. In the Eastern example, UTC times of the hours into the same local hour then. In the Eastern example, UTC times of the
form 5:MM and 6:MM both map to 1:MM when converted to Eastern, but earlier times form 5:MM and 6:MM both map to 1:MM when converted to Eastern, but earlier times
have the :attr:`~datetime.fold` attribute set to 0 and the later times have it set to 1. have the :attr:`~.datetime.fold` attribute set to 0 and the later times have it set to 1.
For example, at the Fall back transition of 2016, we get:: For example, at the Fall back transition of 2016, we get::
>>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc) >>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)
@ -2203,10 +2203,10 @@ For example, at the Fall back transition of 2016, we get::
07:00:00 UTC = 02:00:00 EST 0 07:00:00 UTC = 02:00:00 EST 0
Note that the :class:`.datetime` instances that differ only by the value of the Note that the :class:`.datetime` instances that differ only by the value of the
:attr:`~datetime.fold` attribute are considered equal in comparisons. :attr:`~.datetime.fold` attribute are considered equal in comparisons.
Applications that can't bear wall-time ambiguities should explicitly check the Applications that can't bear wall-time ambiguities should explicitly check the
value of the :attr:`~datetime.fold` attribute or avoid using hybrid value of the :attr:`~.datetime.fold` attribute or avoid using hybrid
:class:`tzinfo` subclasses; there are no ambiguities when using :class:`timezone`, :class:`tzinfo` subclasses; there are no ambiguities when using :class:`timezone`,
or any other fixed-offset :class:`tzinfo` subclass (such as a class representing or any other fixed-offset :class:`tzinfo` subclass (such as a class representing
only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
@ -2214,7 +2214,7 @@ only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
.. seealso:: .. seealso::
:mod:`zoneinfo` :mod:`zoneinfo`
The :mod:`datetime` module has a basic :class:`timezone` class (for The :mod:`!datetime` module has a basic :class:`timezone` class (for
handling arbitrary fixed offsets from UTC) and its :attr:`timezone.utc` handling arbitrary fixed offsets from UTC) and its :attr:`timezone.utc`
attribute (a UTC timezone instance). attribute (a UTC timezone instance).
@ -2232,7 +2232,7 @@ only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
.. _datetime-timezone: .. _datetime-timezone:
:class:`timezone` Objects :class:`timezone` Objects
-------------------------- -------------------------
The :class:`timezone` class is a subclass of :class:`tzinfo`, each The :class:`timezone` class is a subclass of :class:`tzinfo`, each
instance of which represents a timezone defined by a fixed offset from instance of which represents a timezone defined by a fixed offset from
@ -2307,8 +2307,8 @@ Class attributes:
.. _strftime-strptime-behavior: .. _strftime-strptime-behavior:
:meth:`strftime` and :meth:`strptime` Behavior :meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Behavior
---------------------------------------------- --------------------------------------------------------------------
:class:`date`, :class:`.datetime`, and :class:`.time` objects all support a :class:`date`, :class:`.datetime`, and :class:`.time` objects all support a
``strftime(format)`` method, to create a string representing the time under the ``strftime(format)`` method, to create a string representing the time under the
@ -2318,8 +2318,8 @@ Conversely, the :meth:`datetime.strptime` class method creates a
:class:`.datetime` object from a string representing a date and time and a :class:`.datetime` object from a string representing a date and time and a
corresponding format string. corresponding format string.
The table below provides a high-level comparison of :meth:`strftime` The table below provides a high-level comparison of :meth:`~.datetime.strftime`
versus :meth:`strptime`: versus :meth:`~.datetime.strptime`:
+----------------+--------------------------------------------------------+------------------------------------------------------------------------------+ +----------------+--------------------------------------------------------+------------------------------------------------------------------------------+
| | ``strftime`` | ``strptime`` | | | ``strftime`` | ``strptime`` |
@ -2336,8 +2336,8 @@ versus :meth:`strptime`:
.. _format-codes: .. _format-codes:
:meth:`strftime` and :meth:`strptime` Format Codes :meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Format Codes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These methods accept format codes that can be used to parse and format dates:: These methods accept format codes that can be used to parse and format dates::
@ -2476,13 +2476,13 @@ convenience. These parameters all correspond to ISO 8601 date values.
| | naive). | -03:07:12.345216 | | | | naive). | -03:07:12.345216 | |
+-----------+--------------------------------+------------------------+-------+ +-----------+--------------------------------+------------------------+-------+
These may not be available on all platforms when used with the :meth:`strftime` These may not be available on all platforms when used with the :meth:`~.datetime.strftime`
method. The ISO 8601 year and ISO 8601 week directives are not interchangeable method. The ISO 8601 year and ISO 8601 week directives are not interchangeable
with the year and week number directives above. Calling :meth:`strptime` with with the year and week number directives above. Calling :meth:`~.datetime.strptime` with
incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`. incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`.
The full set of format codes supported varies across platforms, because Python The full set of format codes supported varies across platforms, because Python
calls the platform C library's :func:`strftime` function, and platform calls the platform C library's :c:func:`strftime` function, and platform
variations are common. To see the full set of format codes supported on your variations are common. To see the full set of format codes supported on your
platform, consult the :manpage:`strftime(3)` documentation. There are also platform, consult the :manpage:`strftime(3)` documentation. There are also
differences between platforms in handling of unsupported format specifiers. differences between platforms in handling of unsupported format specifiers.
@ -2498,9 +2498,9 @@ Technical Detail
Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's
``time.strftime(fmt, d.timetuple())`` although not all objects support a ``time.strftime(fmt, d.timetuple())`` although not all objects support a
:meth:`timetuple` method. :meth:`~date.timetuple` method.
For the :meth:`datetime.strptime` class method, the default value is For the :meth:`.datetime.strptime` class method, the default value is
``1900-01-01T00:00:00.000``: any components not specified in the format string ``1900-01-01T00:00:00.000``: any components not specified in the format string
will be pulled from the default value. [#]_ will be pulled from the default value. [#]_
@ -2535,27 +2535,27 @@ Notes:
contain non-ASCII characters. contain non-ASCII characters.
(2) (2)
The :meth:`strptime` method can parse years in the full [1, 9999] range, but The :meth:`~.datetime.strptime` method can parse years in the full [1, 9999] range, but
years < 1000 must be zero-filled to 4-digit width. years < 1000 must be zero-filled to 4-digit width.
.. versionchanged:: 3.2 .. versionchanged:: 3.2
In previous versions, :meth:`strftime` method was restricted to In previous versions, :meth:`~.datetime.strftime` method was restricted to
years >= 1900. years >= 1900.
.. versionchanged:: 3.3 .. versionchanged:: 3.3
In version 3.2, :meth:`strftime` method was restricted to In version 3.2, :meth:`~.datetime.strftime` method was restricted to
years >= 1000. years >= 1000.
(3) (3)
When used with the :meth:`strptime` method, the ``%p`` directive only affects When used with the :meth:`~.datetime.strptime` method, the ``%p`` directive only affects
the output hour field if the ``%I`` directive is used to parse the hour. the output hour field if the ``%I`` directive is used to parse the hour.
(4) (4)
Unlike the :mod:`time` module, the :mod:`datetime` module does not support Unlike the :mod:`time` module, the :mod:`!datetime` module does not support
leap seconds. leap seconds.
(5) (5)
When used with the :meth:`strptime` method, the ``%f`` directive When used with the :meth:`~.datetime.strptime` method, the ``%f`` directive
accepts from one to six digits and zero pads on the right. ``%f`` is accepts from one to six digits and zero pads on the right. ``%f`` is
an extension to the set of format characters in the C standard (but an extension to the set of format characters in the C standard (but
implemented separately in datetime objects, and therefore always implemented separately in datetime objects, and therefore always
@ -2568,7 +2568,7 @@ Notes:
For an aware object: For an aware object:
``%z`` ``%z``
:meth:`utcoffset` is transformed into a string of the form :meth:`~.datetime.utcoffset` is transformed into a string of the form
``±HHMM[SS[.ffffff]]``, where ``HH`` is a 2-digit string giving the number ``±HHMM[SS[.ffffff]]``, where ``HH`` is a 2-digit string giving the number
of UTC offset hours, ``MM`` is a 2-digit string giving the number of UTC of UTC offset hours, ``MM`` is a 2-digit string giving the number of UTC
offset minutes, ``SS`` is a 2-digit string giving the number of UTC offset offset minutes, ``SS`` is a 2-digit string giving the number of UTC offset
@ -2576,14 +2576,14 @@ Notes:
offset microseconds. The ``ffffff`` part is omitted when the offset is a offset microseconds. The ``ffffff`` part is omitted when the offset is a
whole number of seconds and both the ``ffffff`` and the ``SS`` part is whole number of seconds and both the ``ffffff`` and the ``SS`` part is
omitted when the offset is a whole number of minutes. For example, if omitted when the offset is a whole number of minutes. For example, if
:meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is :meth:`~.datetime.utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is
replaced with the string ``'-0330'``. replaced with the string ``'-0330'``.
.. versionchanged:: 3.7 .. versionchanged:: 3.7
The UTC offset is not restricted to a whole number of minutes. The UTC offset is not restricted to a whole number of minutes.
.. versionchanged:: 3.7 .. versionchanged:: 3.7
When the ``%z`` directive is provided to the :meth:`strptime` method, When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` method,
the UTC offsets can have a colon as a separator between hours, minutes the UTC offsets can have a colon as a separator between hours, minutes
and seconds. and seconds.
For example, ``'+01:00:00'`` will be parsed as an offset of one hour. For example, ``'+01:00:00'`` will be parsed as an offset of one hour.
@ -2594,11 +2594,11 @@ Notes:
hours, minutes and seconds. hours, minutes and seconds.
``%Z`` ``%Z``
In :meth:`strftime`, ``%Z`` is replaced by an empty string if In :meth:`~.datetime.strftime`, ``%Z`` is replaced by an empty string if
:meth:`tzname` returns ``None``; otherwise ``%Z`` is replaced by the :meth:`~.datetime.tzname` returns ``None``; otherwise ``%Z`` is replaced by the
returned value, which must be a string. returned value, which must be a string.
:meth:`strptime` only accepts certain values for ``%Z``: :meth:`~.datetime.strptime` only accepts certain values for ``%Z``:
1. any value in ``time.tzname`` for your machine's locale 1. any value in ``time.tzname`` for your machine's locale
2. the hard-coded values ``UTC`` and ``GMT`` 2. the hard-coded values ``UTC`` and ``GMT``
@ -2608,23 +2608,23 @@ Notes:
invalid values. invalid values.
.. versionchanged:: 3.2 .. versionchanged:: 3.2
When the ``%z`` directive is provided to the :meth:`strptime` method, an When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` method, an
aware :class:`.datetime` object will be produced. The ``tzinfo`` of the aware :class:`.datetime` object will be produced. The ``tzinfo`` of the
result will be set to a :class:`timezone` instance. result will be set to a :class:`timezone` instance.
(7) (7)
When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used When used with the :meth:`~.datetime.strptime` method, ``%U`` and ``%W`` are only used
in calculations when the day of the week and the calendar year (``%Y``) in calculations when the day of the week and the calendar year (``%Y``)
are specified. are specified.
(8) (8)
Similar to ``%U`` and ``%W``, ``%V`` is only used in calculations when the Similar to ``%U`` and ``%W``, ``%V`` is only used in calculations when the
day of the week and the ISO year (``%G``) are specified in a day of the week and the ISO year (``%G``) are specified in a
:meth:`strptime` format string. Also note that ``%G`` and ``%Y`` are not :meth:`~.datetime.strptime` format string. Also note that ``%G`` and ``%Y`` are not
interchangeable. interchangeable.
(9) (9)
When used with the :meth:`strptime` method, the leading zero is optional When used with the :meth:`~.datetime.strptime` method, the leading zero is optional
for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, ``%j``, ``%U``, for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, ``%j``, ``%U``,
``%W``, and ``%V``. Format ``%y`` does require a leading zero. ``%W``, and ``%V``. Format ``%y`` does require a leading zero.

View file

@ -35,7 +35,6 @@ Doc/library/chunk.rst
Doc/library/collections.rst Doc/library/collections.rst
Doc/library/copy.rst Doc/library/copy.rst
Doc/library/csv.rst Doc/library/csv.rst
Doc/library/datetime.rst
Doc/library/dbm.rst Doc/library/dbm.rst
Doc/library/decimal.rst Doc/library/decimal.rst
Doc/library/email.charset.rst Doc/library/email.charset.rst