<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 27, 2015 at 2:32 PM, Tim Peters <span dir="ltr"><<a href="mailto:tim.peters@gmail.com" target="_blank">tim.peters@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":1fg" class="" style="overflow:hidden">[Tim]<br>
<span class="">>> [...]<br>
>> Stewart, I still don't grasp what your problem is.  The only concrete<br>
>> example I've seen is dealing with this string:<br>
>><br>
>>     2004-10-31 01:15 EST-05:00<br></span><span class="">..<br></span></div></blockquote><div>[Tim] </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":1fg" class="" style="overflow:hidden"><span class="">
<br>
</span>That's fine - I'm trying to get across the idea, not suggest a<br>
specific implementation, and 4 steps are one less than 5 ;-)</div></blockquote></div><div class="gmail_extra"><br></div><div class="gmail_extra">Dealing with simple time strings like this should really be one step:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">>>> ts = '2004-10-31 01:15 EST-05:00'</div><div class="gmail_extra">>>> dt = datetime.strptime(ts.replace('EST', '').replace(':', ''), '%Y-%m-%d %H%M %z')</div><div class="gmail_extra">>>> print(dt)</div><div class="gmail_extra">2004-10-31 01:15:00-05:00</div><div class="gmail_extra"><br></div><div class="gmail_extra">It is unfortunate that we need to massage the input like this before passing it to datetime.strptime().  Ideally,  datetime.strptime() should have a way to at least parse -05:00 as a fixed offset timezone.</div><div class="gmail_extra"><br></div><div class="gmail_extra">However, this problem has nothing to do with PEP 495.  Once you have the UTC offset - there is no ambiguity.  The other 01:15 would be  "2004-10-31 01:15 -04:00." The EST part is redundant and is dropped explicitly in my solution and not used in the solutions by Tim and Guido. </div></div><br><br></div></div>