Skip to content

Commit 1d88eb1

Browse files
uatacherlend-aaslandhugovkStanFromIreland
committed
[3.13] 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 0e57600 commit 1d88eb1

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
@@ -65,7 +65,7 @@ understand and to work with, at the cost of ignoring some aspects of reality.
6565

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

@@ -432,9 +432,9 @@ objects (see below).
432432

433433
.. versionchanged:: 3.2
434434
Floor division and true division of a :class:`timedelta` object by another
435-
:class:`timedelta` object are now supported, as are remainder operations and
435+
:class:`!timedelta` object are now supported, as are remainder operations and
436436
the :func:`divmod` function. True division and multiplication of a
437-
:class:`timedelta` object by a :class:`float` object are now supported.
437+
:class:`!timedelta` object by a :class:`float` object are now supported.
438438

439439
:class:`timedelta` objects support equality and order comparisons.
440440

@@ -664,7 +664,7 @@ Notes:
664664
In other words, ``date1 < date2`` if and only if ``date1.toordinal() <
665665
date2.toordinal()``.
666666

667-
Order comparison between a :class:`!date` object that is not also a
667+
Order comparison between a :class:`date` object that is not also a
668668
:class:`.datetime` instance and a :class:`!datetime` object raises
669669
:exc:`TypeError`.
670670

@@ -877,7 +877,7 @@ from a :class:`date` object and a :class:`.time` object.
877877

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

882882
Constructor:
883883

@@ -1043,7 +1043,7 @@ Other constructors, all class methods:
10431043
are equal to the given :class:`.time` object's. If the *tzinfo*
10441044
argument is provided, its value is used to set the :attr:`.tzinfo` attribute
10451045
of the result, otherwise the :attr:`~.time.tzinfo` attribute of the *time* argument
1046-
is used. If the *date* argument is a :class:`.datetime` object, its time components
1046+
is used. If the *date* argument is a :class:`!datetime` object, its time components
10471047
and :attr:`.tzinfo` attributes are ignored.
10481048

10491049
For any :class:`.datetime` object ``d``,
@@ -1247,7 +1247,7 @@ Supported operations:
12471247
datetime, and no time zone adjustments are done even if the input is aware.
12481248

12491249
(3)
1250-
Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined only if
1250+
Subtraction of a :class:`.datetime` from a :class:`!datetime` is defined only if
12511251
both operands are naive, or if both are aware. If one is aware and the other is
12521252
naive, :exc:`TypeError` is raised.
12531253

@@ -1265,15 +1265,15 @@ Supported operations:
12651265
:class:`.datetime` objects are equal if they represent the same date
12661266
and time, taking into account the time zone.
12671267

1268-
Naive and aware :class:`!datetime` objects are never equal.
1268+
Naive and aware :class:`.datetime` objects are never equal.
12691269

12701270
If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
12711271
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
12721272
the base datetimes are compared.
12731273
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
12741274
attributes, the comparison acts as comparands were first converted to UTC
12751275
datetimes except that the implementation never overflows.
1276-
:class:`!datetime` instances in a repeated interval are never equal to
1276+
:class:`.datetime` instances in a repeated interval are never equal to
12771277
:class:`!datetime` instances in other time zone.
12781278

12791279
(5)
@@ -1470,7 +1470,7 @@ Instance methods:
14701470

14711471
Naive :class:`.datetime` instances are assumed to represent local
14721472
time and this method relies on the platform C :c:func:`mktime`
1473-
function to perform the conversion. Since :class:`.datetime`
1473+
function to perform the conversion. Since :class:`!datetime`
14741474
supports wider range of values than :c:func:`mktime` on many
14751475
platforms, this method may raise :exc:`OverflowError` or :exc:`OSError`
14761476
for times far in the past or far in the future.
@@ -1911,7 +1911,7 @@ Instance methods:
19111911
19121912
Return a new :class:`.time` with the same values, but with specified
19131913
parameters updated. Note that ``tzinfo=None`` can be specified to create a
1914-
naive :class:`.time` from an aware :class:`.time`, without conversion of the
1914+
naive :class:`!time` from an aware :class:`!time`, without conversion of the
19151915
time data.
19161916

19171917
:class:`.time` objects are also supported by generic function
@@ -2053,14 +2053,14 @@ Examples of working with a :class:`.time` object::
20532053

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

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

@@ -2123,11 +2123,11 @@ Examples of working with a :class:`.time` object::
21232123
``tz.utcoffset(dt) - tz.dst(dt)``
21242124

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

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

21702170
The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`.
21712171

21722172

21732173
These methods are called by a :class:`.datetime` or :class:`.time` object, in
2174-
response to their methods of the same names. A :class:`.datetime` object passes
2175-
itself as the argument, and a :class:`.time` object passes ``None`` as the
2174+
response to their methods of the same names. A :class:`!datetime` object passes
2175+
itself as the argument, and a :class:`!time` object passes ``None`` as the
21762176
argument. A :class:`tzinfo` subclass's methods should therefore be prepared to
2177-
accept a *dt* argument of ``None``, or of class :class:`.datetime`.
2177+
accept a *dt* argument of ``None``, or of class :class:`!datetime`.
21782178

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

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

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

23012301
.. seealso::

0 commit comments

Comments
 (0)