Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created July 6, 2011 21:08
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamelafox/1068330 to your computer and use it in GitHub Desktop.
Save pamelafox/1068330 to your computer and use it in GitHub Desktop.
SimpleGeo Timezone Calculation on Python App Engine
class User(db.Model):
location = db.StringProperty()
timezone = db.StringProperty(default='America/Los_Angeles')
# Do this once per user
def calculate_timezone(self):
from simplegeo import Client
client = Client('oauth key', 'oauth secret SHH')
response = client.context.get_context_by_address(self.location)
for feature in response['features']:
if feature['classifiers'][0]['category'] == 'Time Zone':
timezone = feature['name']
self.timezone = timezone
self.put()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment