Skip to content

Commit 5995400

Browse files
serhiy-storchakapull[bot]
authored andcommitted
gh-116035: Document that both tzinfo and fold are ignored in comparisons if tzinfo is the same (GH-116187)
This mostly restores information removed in c12240e (GH-114749).
1 parent 610d8a3 commit 5995400

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Doc/library/datetime.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,9 @@ Supported operations:
12091209

12101210
Naive and aware :class:`!datetime` objects are never equal.
12111211

1212+
If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
1213+
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
1214+
the base datetimes are compared.
12121215
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
12131216
attributes, the comparison acts as comparands were first converted to UTC
12141217
datetimes except that the implementation never overflows.
@@ -1222,6 +1225,9 @@ Supported operations:
12221225
Order comparison between naive and aware :class:`.datetime` objects
12231226
raises :exc:`TypeError`.
12241227

1228+
If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
1229+
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
1230+
the base datetimes are compared.
12251231
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
12261232
attributes, the comparison acts as comparands were first converted to UTC
12271233
datetimes except that the implementation never overflows.
@@ -1778,8 +1784,8 @@ Naive and aware :class:`!time` objects are never equal.
17781784
Order comparison between naive and aware :class:`!time` objects raises
17791785
:exc:`TypeError`.
17801786

1781-
If both comparands are aware, and have
1782-
the same :attr:`~.time.tzinfo` attribute, the common :attr:`!tzinfo` attribute is
1787+
If both comparands are aware, and have the same :attr:`~.time.tzinfo`
1788+
attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are
17831789
ignored and the base times are compared. If both comparands are aware and
17841790
have different :attr:`!tzinfo` attributes, the comparands are first adjusted by
17851791
subtracting their UTC offsets (obtained from ``self.utcoffset()``).

0 commit comments

Comments
 (0)