Skip to content

Commit 532e62e

Browse files
uatacherlend-aaslandhugovkStanFromIreland
committed
[3.14] gh-140715: Improve class reference links on datetime.rst (GH-123980)
(cherry picked from commit 6c417e4) Co-authored-by: edson duarte <eduarte.uatach@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 4152bbb commit 532e62e

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Doc/library/datetime.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ understand and to work with, at the cost of ignoring some aspects of reality.
6464

6565
For applications requiring aware objects, :class:`.datetime` and :class:`.time`
6666
objects have an optional time zone information attribute, :attr:`!tzinfo`, that
67-
can be set to an instance of a subclass of the abstract :class:`tzinfo` class.
67+
can be set to an instance of a subclass of the abstract :class:`!tzinfo` class.
6868
These :class:`tzinfo` objects capture information about the offset from UTC
6969
time, the time zone name, and whether daylight saving time is in effect.
7070

@@ -436,9 +436,9 @@ objects (see below).
436436

437437
.. versionchanged:: 3.2
438438
Floor division and true division of a :class:`timedelta` object by another
439-
:class:`timedelta` object are now supported, as are remainder operations and
439+
:class:`!timedelta` object are now supported, as are remainder operations and
440440
the :func:`divmod` function. True division and multiplication of a
441-
:class:`timedelta` object by a :class:`float` object are now supported.
441+
:class:`!timedelta` object by a :class:`float` object are now supported.
442442

443443
:class:`timedelta` objects support equality and order comparisons.
444444

@@ -706,7 +706,7 @@ Notes:
706706
In other words, ``date1 < date2`` if and only if ``date1.toordinal() <
707707
date2.toordinal()``.
708708

709-
Order comparison between a :class:`!date` object that is not also a
709+
Order comparison between a :class:`date` object that is not also a
710710
:class:`.datetime` instance and a :class:`!datetime` object raises
711711
:exc:`TypeError`.
712712

@@ -922,7 +922,7 @@ from a :class:`date` object and a :class:`.time` object.
922922

923923
Like a :class:`date` object, :class:`.datetime` assumes the current Gregorian
924924
calendar extended in both directions; like a :class:`.time` object,
925-
:class:`.datetime` assumes there are exactly 3600\*24 seconds in every day.
925+
:class:`!datetime` assumes there are exactly 3600\*24 seconds in every day.
926926

927927
Constructor:
928928

@@ -1094,7 +1094,7 @@ Other constructors, all class methods:
10941094
are equal to the given :class:`.time` object's. If the *tzinfo*
10951095
argument is provided, its value is used to set the :attr:`.tzinfo` attribute
10961096
of the result, otherwise the :attr:`~.time.tzinfo` attribute of the *time* argument
1097-
is used. If the *date* argument is a :class:`.datetime` object, its time components
1097+
is used. If the *date* argument is a :class:`!datetime` object, its time components
10981098
and :attr:`.tzinfo` attributes are ignored.
10991099

11001100
For any :class:`.datetime` object ``d``,
@@ -1300,7 +1300,7 @@ Supported operations:
13001300
datetime, and no time zone adjustments are done even if the input is aware.
13011301

13021302
(3)
1303-
Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined only if
1303+
Subtraction of a :class:`.datetime` from a :class:`!datetime` is defined only if
13041304
both operands are naive, or if both are aware. If one is aware and the other is
13051305
naive, :exc:`TypeError` is raised.
13061306

@@ -1318,15 +1318,15 @@ Supported operations:
13181318
:class:`.datetime` objects are equal if they represent the same date
13191319
and time, taking into account the time zone.
13201320

1321-
Naive and aware :class:`!datetime` objects are never equal.
1321+
Naive and aware :class:`.datetime` objects are never equal.
13221322

13231323
If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
13241324
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
13251325
the base datetimes are compared.
13261326
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
13271327
attributes, the comparison acts as comparands were first converted to UTC
13281328
datetimes except that the implementation never overflows.
1329-
:class:`!datetime` instances in a repeated interval are never equal to
1329+
:class:`.datetime` instances in a repeated interval are never equal to
13301330
:class:`!datetime` instances in other time zone.
13311331

13321332
(5)
@@ -1526,7 +1526,7 @@ Instance methods:
15261526

15271527
Naive :class:`.datetime` instances are assumed to represent local
15281528
time and this method relies on the platform C :c:func:`mktime`
1529-
function to perform the conversion. Since :class:`.datetime`
1529+
function to perform the conversion. Since :class:`!datetime`
15301530
supports wider range of values than :c:func:`mktime` on many
15311531
platforms, this method may raise :exc:`OverflowError` or :exc:`OSError`
15321532
for times far in the past or far in the future.
@@ -1988,7 +1988,7 @@ Instance methods:
19881988
19891989
Return a new :class:`.time` with the same values, but with specified
19901990
parameters updated. Note that ``tzinfo=None`` can be specified to create a
1991-
naive :class:`.time` from an aware :class:`.time`, without conversion of the
1991+
naive :class:`!time` from an aware :class:`!time`, without conversion of the
19921992
time data.
19931993

19941994
:class:`.time` objects are also supported by generic function
@@ -2132,14 +2132,14 @@ Examples of working with a :class:`.time` object::
21322132

21332133
An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the
21342134
constructors for :class:`.datetime` and :class:`.time` objects. The latter objects
2135-
view their attributes as being in local time, and the :class:`tzinfo` object
2135+
view their attributes as being in local time, and the :class:`!tzinfo` object
21362136
supports methods revealing offset of local time from UTC, the name of the time
21372137
zone, and DST offset, all relative to a date or time object passed to them.
21382138

21392139
You need to derive a concrete subclass, and (at least)
21402140
supply implementations of the standard :class:`tzinfo` methods needed by the
21412141
:class:`.datetime` methods you use. The :mod:`!datetime` module provides
2142-
:class:`timezone`, a simple concrete subclass of :class:`tzinfo` which can
2142+
:class:`timezone`, a simple concrete subclass of :class:`!tzinfo` which can
21432143
represent time zones with fixed offset from UTC such as UTC itself or North
21442144
American EST and EDT.
21452145

@@ -2202,11 +2202,11 @@ Examples of working with a :class:`.time` object::
22022202
``tz.utcoffset(dt) - tz.dst(dt)``
22032203

22042204
must return the same result for every :class:`.datetime` *dt* with ``dt.tzinfo ==
2205-
tz``. For sane :class:`tzinfo` subclasses, this expression yields the time
2205+
tz``. For sane :class:`!tzinfo` subclasses, this expression yields the time
22062206
zone's "standard offset", which should not depend on the date or the time, but
22072207
only on geographic location. The implementation of :meth:`datetime.astimezone`
22082208
relies on this, but cannot detect violations; it's the programmer's
2209-
responsibility to ensure it. If a :class:`tzinfo` subclass cannot guarantee
2209+
responsibility to ensure it. If a :class:`!tzinfo` subclass cannot guarantee
22102210
this, it may be able to override the default implementation of
22112211
:meth:`tzinfo.fromutc` to work correctly with :meth:`~.datetime.astimezone` regardless.
22122212

@@ -2243,28 +2243,28 @@ Examples of working with a :class:`.time` object::
22432243
valid replies. Return ``None`` if a string name isn't known. Note that this is
22442244
a method rather than a fixed string primarily because some :class:`tzinfo`
22452245
subclasses will wish to return different names depending on the specific value
2246-
of *dt* passed, especially if the :class:`tzinfo` class is accounting for
2246+
of *dt* passed, especially if the :class:`!tzinfo` class is accounting for
22472247
daylight time.
22482248

22492249
The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`.
22502250

22512251

22522252
These methods are called by a :class:`.datetime` or :class:`.time` object, in
2253-
response to their methods of the same names. A :class:`.datetime` object passes
2254-
itself as the argument, and a :class:`.time` object passes ``None`` as the
2253+
response to their methods of the same names. A :class:`!datetime` object passes
2254+
itself as the argument, and a :class:`!time` object passes ``None`` as the
22552255
argument. A :class:`tzinfo` subclass's methods should therefore be prepared to
2256-
accept a *dt* argument of ``None``, or of class :class:`.datetime`.
2256+
accept a *dt* argument of ``None``, or of class :class:`!datetime`.
22572257

22582258
When ``None`` is passed, it's up to the class designer to decide the best
22592259
response. For example, returning ``None`` is appropriate if the class wishes to
22602260
say that time objects don't participate in the :class:`tzinfo` protocols. It
22612261
may be more useful for ``utcoffset(None)`` to return the standard UTC offset, as
22622262
there is no other convention for discovering the standard offset.
22632263

2264-
When a :class:`.datetime` object is passed in response to a :class:`.datetime`
2264+
When a :class:`.datetime` object is passed in response to a :class:`!datetime`
22652265
method, ``dt.tzinfo`` is the same object as *self*. :class:`tzinfo` methods can
2266-
rely on this, unless user code calls :class:`tzinfo` methods directly. The
2267-
intent is that the :class:`tzinfo` methods interpret *dt* as being in local
2266+
rely on this, unless user code calls :class:`!tzinfo` methods directly. The
2267+
intent is that the :class:`!tzinfo` methods interpret *dt* as being in local
22682268
time, and not need worry about objects in other time zones.
22692269

22702270
There is one more :class:`tzinfo` method that a subclass may wish to override:
@@ -2374,7 +2374,7 @@ Note that the :class:`.datetime` instances that differ only by the value of the
23742374
Applications that can't bear wall-time ambiguities should explicitly check the
23752375
value of the :attr:`~.datetime.fold` attribute or avoid using hybrid
23762376
:class:`tzinfo` subclasses; there are no ambiguities when using :class:`timezone`,
2377-
or any other fixed-offset :class:`tzinfo` subclass (such as a class representing
2377+
or any other fixed-offset :class:`!tzinfo` subclass (such as a class representing
23782378
only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
23792379

23802380
.. seealso::

0 commit comments

Comments
 (0)