From a937113090b8e4b8bf8e4594835080aaed2971c2 Mon Sep 17 00:00:00 2001 From: John Belmonte Date: Mon, 30 Jan 2023 16:51:13 +0900 Subject: [PATCH 1/2] datetime.rst: correct timedelta description It was confusingly claimed that `timedelta` could represent the difference between two `datetime.time` objects. Subtraction of two `datetime.time` values is not allowed, nor can a `timedelta` be added to a `time`. And specifically, this conflicted text in the "timedelta Objects" section, stating "A timedelta object represents [...] the difference between two dates or times." --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 735c3b24f81509e..0b24404bcfd83d6 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -130,7 +130,7 @@ Available Types .. class:: timedelta :noindex: - A duration expressing the difference between two :class:`date`, :class:`.time`, + A duration expressing the difference between two :class:`date` or :class:`.datetime` instances to microsecond resolution. From ed94b15e8f6099f04237a7d5c4c6922470bbacca Mon Sep 17 00:00:00 2001 From: John Belmonte Date: Fri, 2 Feb 2024 13:06:40 -0800 Subject: [PATCH 2/2] * clarify the text in 'datetime Objects' section too * list `datetime` ahead of `date`, since it's more common when using `timedelta` --- Doc/library/datetime.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 0b24404bcfd83d6..930af6cbbe9e8d1 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -130,8 +130,8 @@ Available Types .. class:: timedelta :noindex: - A duration expressing the difference between two :class:`date` - or :class:`.datetime` instances to microsecond resolution. + A duration expressing the difference between two :class:`.datetime` + or :class:`date` instances to microsecond resolution. .. class:: tzinfo @@ -203,7 +203,7 @@ objects. -------------------------- A :class:`timedelta` object represents a duration, the difference between two -dates or times. +:class:`.datetime` or :class:`date` instances. .. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)