Skip to content

Commit 94e375b

Browse files
serhiy-storchakamiss-islington
authored andcommitted
pythongh-116035: Document that both tzinfo and fold are ignored in comparisons if tzinfo is the same (pythonGH-116187)
This mostly restores information removed in c12240e (pythonGH-114749). (cherry picked from commit 05b0490) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent c363936 commit 94e375b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Doc/library/datetime.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@ Supported operations:
11851185
that are not also :class:`!datetime` instances, even if they represent
11861186
the same date.
11871187

1188+
If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
1189+
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
1190+
the base datetimes are compared.
11881191
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
11891192
attributes, the comparison acts as comparands were first converted to UTC
11901193
datetimes except that the implementation never overflows.
@@ -1199,6 +1202,9 @@ Supported operations:
11991202
as well as a :class:`!datetime` object and a :class:`!date` object
12001203
that is not also a :class:`!datetime` instance, raises :exc:`TypeError`.
12011204

1205+
If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
1206+
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
1207+
the base datetimes are compared.
12021208
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
12031209
attributes, the comparison acts as comparands were first converted to UTC
12041210
datetimes except that the implementation never overflows.
@@ -1744,8 +1750,8 @@ Naive and aware :class:`!time` objects are never equal.
17441750
Order comparison between naive and aware :class:`!time` objects raises
17451751
:exc:`TypeError`.
17461752

1747-
If both comparands are aware, and have
1748-
the same :attr:`~.time.tzinfo` attribute, the common :attr:`!tzinfo` attribute is
1753+
If both comparands are aware, and have the same :attr:`~.time.tzinfo`
1754+
attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are
17491755
ignored and the base times are compared. If both comparands are aware and
17501756
have different :attr:`!tzinfo` attributes, the comparands are first adjusted by
17511757
subtracting their UTC offsets (obtained from ``self.utcoffset()``).

0 commit comments

Comments
 (0)