It turns out the answer to this is that strptime in python does not really support timezones: "datetime.datetime.strptime('PDT', '%Z')" will throw ValueError whenever locale time is not PDT (or PST). "UTC" and "GMT" don't throw an exception, but are not actually taken into consideration. So, any python gurus out there know a reliable way to convert from a string that contains a timezone to a UTC datetime?
Lenza blog.lenza.org On Feb 24, 11:47 am, lenza <le...@lenza.org> wrote: > I am trying to parse dates in an App Engine app. > datetime.datetime.strptime is failing with a format error in the > development environment with the following error: > > ERROR 2009-02-24 7:37:03,909 __init__.py]timedata did not match > format: data=2009-02-24, 11:28AM PST fmt=%Y-%m-%d, %I:%M%p %Z > > However, this works fine in Python: > > >>> import datetime > >>> datetime.datetime.strptime("2009-02-24, 11:28AM PST", "%Y-%m-%d, %I:%M%p > >>> %Z") > > datetime.datetime(2009, 2, 24, 11, 28) > > This issue was previously reported > here:http://groups.google.com/group/google-appengine/browse_frm/thread/b36... > > As Mariza suggests there, everything works fine when the timezone is > left out of the parsing. The same occurs fortime.strptime. Anyone > know what is causing this or have a good workaround? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---