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 mrshannon
Recipients belopolsky, mrshannon
Date 2017-05-23.21:21:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495574506.4.0.0164833880692.issue30443@psf.upfronthosting.co.za>
In-reply-to
Content
datetime.datetime.__add__ is currently implemented by converting the date into a datetime.timedelta object (using toordinal) before adding it to the other (timedelta) object and reconstructing with datetime.combine.  With this method, fold will always be set to 0.

There are two cases that will produce an incorrect result (assuming positive timedelta for examples).

1. fold=0 and the timedelta is large enough to push the time into or past a fold.  Either fold will be 0 and not 1 as it should or the time will be too far ahead by the size of the fold.

2. fold=1 and the timedelta is small enough to leave the time in the fold but fold will be set to 0.  This results in the time being too far behind by the size of the fold.

A possible fix is to convert to UTC before adding the timedelta and call self._tzinfo.fromutc() on the result.
History
Date User Action Args
2017-05-23 21:21:46mrshannonsetrecipients: + mrshannon, belopolsky
2017-05-23 21:21:46mrshannonsetmessageid: <1495574506.4.0.0164833880692.issue30443@psf.upfronthosting.co.za>
2017-05-23 21:21:46mrshannonlinkissue30443 messages
2017-05-23 21:21:46mrshannoncreate