Skip to content

Commit 6c417e4

Browse files
uatacherlend-aaslandhugovkStanFromIreland
authored
gh-140715: Improve class reference links on datetime.rst (#123980)
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 c9b96b1 commit 6c417e4

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

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

@@ -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

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

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

@@ -921,7 +921,7 @@ from a :class:`date` object and a :class:`.time` object.
921921

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

926926
Constructor:
927927

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

11031103
For any :class:`.datetime` object ``d``,
@@ -1303,7 +1303,7 @@ Supported operations:
13031303
datetime, and no time zone adjustments are done even if the input is aware.
13041304

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

@@ -1321,15 +1321,15 @@ Supported operations:
13211321
:class:`.datetime` objects are equal if they represent the same date
13221322
and time, taking into account the time zone.
13231323

1324-
Naive and aware :class:`!datetime` objects are never equal.
1324+
Naive and aware :class:`.datetime` objects are never equal.
13251325

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

13351335
(5)
@@ -1529,7 +1529,7 @@ Instance methods:
15291529

15301530
Naive :class:`.datetime` instances are assumed to represent local
15311531
time and this method relies on platform C functions to perform
1532-
the conversion. Since :class:`.datetime` supports a wider range of
1532+
the conversion. Since :class:`!datetime` supports a wider range of
15331533
values than the platform C functions on many platforms, this
15341534
method may raise :exc:`OverflowError` or :exc:`OSError` for times
15351535
far in the past or far in the future.
@@ -1995,7 +1995,7 @@ Instance methods:
19951995
19961996
Return a new :class:`.time` with the same values, but with specified
19971997
parameters updated. Note that ``tzinfo=None`` can be specified to create a
1998-
naive :class:`.time` from an aware :class:`.time`, without conversion of the
1998+
naive :class:`!time` from an aware :class:`!time`, without conversion of the
19991999
time data.
20002000

20012001
:class:`.time` objects are also supported by generic function
@@ -2139,14 +2139,14 @@ Examples of working with a :class:`.time` object::
21392139

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

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

@@ -2209,11 +2209,11 @@ Examples of working with a :class:`.time` object::
22092209
``tz.utcoffset(dt) - tz.dst(dt)``
22102210

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

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

22562256
The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`.
22572257

22582258

22592259
These methods are called by a :class:`.datetime` or :class:`.time` object, in
2260-
response to their methods of the same names. A :class:`.datetime` object passes
2261-
itself as the argument, and a :class:`.time` object passes ``None`` as the
2260+
response to their methods of the same names. A :class:`!datetime` object passes
2261+
itself as the argument, and a :class:`!time` object passes ``None`` as the
22622262
argument. A :class:`tzinfo` subclass's methods should therefore be prepared to
2263-
accept a *dt* argument of ``None``, or of class :class:`.datetime`.
2263+
accept a *dt* argument of ``None``, or of class :class:`!datetime`.
22642264

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

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

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

23872387
.. seealso::

0 commit comments

Comments
 (0)