On Fri, Aug 15, 2014 at 11:43 AM, Denis McMahon <denismfmcma...@gmail.com> wrote: > On Fri, 15 Aug 2014 09:23:02 -0600, Ian Kelly wrote: > >> On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon >> <denismfmcma...@gmail.com> wrote: >>> On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: >>> >>> On further inspection, it seems that strptime() in 2.7 doesn't handle >>> %z at all. In 3.2, it ignores the value it gets, because there's no >>> practical way to select the "right" tz string from the offset. >> >> I'm not sure when %z was added, but it's worth noting that it doesn't >> seem to be documented earlier than 3.3. > > There may be some confusion because %z is in the table of strftime and > strptime format chars on the 2.7.8 docs at > > https://docs.python.org/2/library/datetime.html#strftime-and-strptime- > behavior > > but I suspect it's only applicable to strftime in that release.
Ah, interesting. I was looking at the time.strptime docs. I incorrectly assumed that since help(datetime.strptime) defers to help(time.strptime), the docs would also. I note it says that "datetime.strptime(date_string, format) is equivalent to datetime(*(time.strptime(date_string, format)[0:6]))", but clearly that's not the case when the format includes %z. -- https://mail.python.org/mailman/listinfo/python-list