<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 19, 2015 at 7:08 PM, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 08/19/2015 03:30 PM, Alexander Belopolsky wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If we all understand that '2015-03-08T12:00:00-05:00', '2015-03-08T13:00:00-04:00'<br>
and '2015-03-09T04:00:00+11:00' are different spellings of the same time, where is<br>
a bug in the following calculation?<br>
<br>
>>> print(lt)<br>
2015-03-07 12:00:00-05:00<br>
>>> lt += timedelta(1)<br>
>>> print(lt)<br>
2015-03-08 12:00:00-05:00<br>
</blockquote>
<br></span>
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.</blockquote></div><br>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. </div></div>