This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author René Hernández Remedios
Recipients René Hernández Remedios
Date 2017-05-30.21:22:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496179333.45.0.413102703331.issue30516@psf.upfronthosting.co.za>
In-reply-to
Content
In the documentation for the supported arithmetic operations for a datetime object, there is the following note, among other:

datetime2 = datetime1 - timedelta

Comment:
Computes the datetime2 such that datetime2 + timedelta == datetime1. As for addition, the result has the same 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.

While reading the source code for __sub__ operation I found in the first few lines:

Line 1885:
def __sub__(self, other):
    "Subtract two datetimes, or a datetime and a timedelta."
    if not isinstance(other, datetime):
        if isinstance(other, timedelta):
            return self + -other
        return NotImplemented

Is the documentation in contradiction with the actual implementation?
History
Date User Action Args
2017-05-30 21:22:13René Hernández Remediossetrecipients: + René Hernández Remedios
2017-05-30 21:22:13René Hernández Remediossetmessageid: <1496179333.45.0.413102703331.issue30516@psf.upfronthosting.co.za>
2017-05-30 21:22:13René Hernández Remedioslinkissue30516 messages
2017-05-30 21:22:13René Hernández Remedioscreate