summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-03-01 17:16:29 (GMT)
committerGitHub <noreply@github.com>2024-03-01 17:16:29 (GMT)
commit05b04903a14279421ecdc6522b8202822de6ebb5 (patch)
tree9680de5614db1e519853dcf73919c1d53d0558f0
parent936d4611d63d0c109e05d385e99acc0592eff341 (diff)
downloadcpython-05b04903a14279421ecdc6522b8202822de6ebb5.zip
cpython-05b04903a14279421ecdc6522b8202822de6ebb5.tar.gz
cpython-05b04903a14279421ecdc6522b8202822de6ebb5.tar.bz2
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 c12240ed28aac6494750e00143bc550c4d6d8ad1 (GH-114749).
-rw-r--r--Doc/library/datetime.rst10
1 files changed, 8 insertions, 2 deletions
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 4602132..1905c9e 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -1209,6 +1209,9 @@ Supported operations:
Naive and aware :class:`!datetime` objects are never equal.
+ If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
+ the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
+ the base datetimes are compared.
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
attributes, the comparison acts as comparands were first converted to UTC
datetimes except that the implementation never overflows.
@@ -1222,6 +1225,9 @@ Supported operations:
Order comparison between naive and aware :class:`.datetime` objects
raises :exc:`TypeError`.
+ If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
+ the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
+ the base datetimes are compared.
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
attributes, the comparison acts as comparands were first converted to UTC
datetimes except that the implementation never overflows.
@@ -1778,8 +1784,8 @@ Naive and aware :class:`!time` objects are never equal.
Order comparison between naive and aware :class:`!time` objects raises
:exc:`TypeError`.
-If both comparands are aware, and have
-the same :attr:`~.time.tzinfo` attribute, the common :attr:`!tzinfo` attribute is
+If both comparands are aware, and have the same :attr:`~.time.tzinfo`
+attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are
ignored and the base times are compared. If both comparands are aware and
have different :attr:`!tzinfo` attributes, the comparands are first adjusted by
subtracting their UTC offsets (obtained from ``self.utcoffset()``).