Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.6] bpo-30516: Fix documentation issue with -timedelta in datetime (GH-7348) #8092

Merged
merged 1 commit into from
Jul 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Supported operations:
+--------------------------------+-----------------------------------------------+
| ``t1 = t2 - t3`` | Difference of *t2* and *t3*. Afterwards *t1* |
| | == *t2* - *t3* and *t2* == *t1* + *t3* are |
| | true. (1) |
| | true. (1)(6) |
+--------------------------------+-----------------------------------------------+
| ``t1 = t2 * i or t1 = i * t2`` | Delta multiplied by an integer. |
| | Afterwards *t1* // i == *t2* is true, |
Expand Down Expand Up @@ -316,6 +316,11 @@ Notes:
>>> print(_)
-1 day, 19:00:00

(6)
The expression ``t2 - t3`` will always be equal to the expression ``t2 + (-t3)`` except
when t3 is equal to ``timedelta.max``; in that case the former will produce a result
while the latter will overflow.

In addition to the operations listed above :class:`timedelta` objects support
certain additions and subtractions with :class:`date` and :class:`.datetime`
objects (see below).
Expand Down Expand Up @@ -497,8 +502,6 @@ Notes:
:const:`MINYEAR` or larger than :const:`MAXYEAR`.

(2)
This isn't quite equivalent to date1 + (-timedelta), because -timedelta in
isolation can overflow in cases where date1 - timedelta does not.
``timedelta.seconds`` and ``timedelta.microseconds`` are ignored.

(3)
Expand Down Expand Up @@ -930,8 +933,6 @@ Supported operations:
Computes the datetime2 such that datetime2 + timedelta == datetime1. As for
addition, the result has the same :attr:`~.datetime.tzinfo` attribute as the input
datetime, and no time zone adjustments are done even if the input is aware.
This isn't quite equivalent to datetime1 + (-timedelta), because -timedelta
in isolation can overflow in cases where datetime1 - timedelta does not.

(3)
Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined only if
Expand Down