[Datetime-SIG] PEP-0500 (Alternative datetime arithmetic) Was: PEP 495 ... is ready ...
Alexander Belopolsky
alexander.belopolsky at gmail.com
Thu Aug 20 01:32:57 CEST 2015
On Wed, Aug 19, 2015 at 7:08 PM, Ethan Furman <ethan at stoneleaf.us> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150819/afdf28e6/attachment-0001.html>
More information about the Datetime-SIG
mailing list