I’m using Google App Engine with python. And I can’t install third party library.
I though this should work, but it actually runs without error but it returns current time timezone is not applied.
What did I do wrong?
from datetime import tzinfo, timedelta, datetime
class Seoul_tzinfo(tzinfo):
def utcoffset(self, dt):
return timedelta(hours=9)
def dst(self, dt):
return timedelta(0)
greeting.date = datetime.now( Seoul_tzinfo() )
Are you talking about when the entity is fetched from the database? If so, appengine stores all dt properties in UTC; when you put(), it simply discards the tz info. The wisest thing would be to convert your dt to UTC (using astimezone()), and convert back when you fetch it from the datastore.
(See http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#DateTimeProperty )