UnknownTimeZoneError
Brian
bdelegan at gmail.com
Tue Mar 31 08:34:53 EDT 2009
I'm running App Engine with Django. I'm having troubles executing
timezone conversion via pytz. I have looked at the Google example
implementation. The following works in IDLE:
>>> import pytz
>>> from pytz import common_timezones
>>> from pytz import timezone
>>> import datetime
>>> timestamp = datetime.datetime.utcnow()
>>> print timestamp
2009-03-22 11:02:41.578000
>>> translated = timestamp.replace(tzinfo=pytz.utc).astimezone(timezone('US/Central'))
>>> print translated
2009-03-22 06:02:41.578000-05:00
I have tried to run the following in my app (modules imported, too):
def tz(request):
timestamp = datetime.datetime.utcnow()
translated = timestamp.replace(tzinfo=pytz.utc).astimezone
(timezone
('US/Central'))
return respond(request, user, 'tz',
{'translated':translated,'timestamp':timestamp})
When I pull up the page, I get the following error:
UnknownTimeZoneError at /tz
'US/Central'
Request Method: GET
Request URL: http://localhost:8080/tz
Exception Type: UnknownTimeZoneError
Exception Value: 'US/Central'
Does this not work in App Engine for some reason?
More information about the Python-list
mailing list