On Wed, Aug 19, 2015 at 7:08 PM, Ethan Furman <[email protected]> wrote:
> On 08/19/2015 03:30 PM, Alexander Belopolsky wrote: > > If we all understand that '2015-03-08T12:00:00-05:00', >> '2015-03-08T13:00:00-04:00' >> and '2015-03-09T04:00:00+11:00' are different spellings of the same >> time, where is >> a bug in the following calculation? >> >> >>> print(lt) >> 2015-03-07 12:00:00-05:00 >> >>> lt += timedelta(1) >> >>> print(lt) >> 2015-03-08 12:00:00-05:00 >> > > Well, let's say I live in New York, so all winter long I've been seeing > things like "2015-01-17 9:37:51-05:00", etc. and then the time switches in > March and I fail to notice that the "-05:00" is still "-05:00" and not > "-04:00" -- especially since my watch, clock, smart phone, etc., don't > display the offset -- well, something bad will happen: exactly what depends > on what the user was expecting when adding a day. In this case, add .astimezone() call before printing the time in your program. What can I say, if you want to see the result of 1 + 1 in binary -- call bin() -- Python's "+" won't do it for you.
_______________________________________________ Datetime-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/datetime-sig The PSF Code of Conduct applies to this mailing list: https://www.python.org/psf/codeofconduct/
