Skip to content

Instantly share code, notes, and snippets.

@tosh
Created March 21, 2011 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tosh/879829 to your computer and use it in GitHub Desktop.
Save tosh/879829 to your computer and use it in GitHub Desktop.
convert python dates into iso strings for javascript
def dto(self):
"""
Data Transfer Object
http://en.wikipedia.org/wiki/Data_transfer_object
datetimes are serialized to http://www.ietf.org/rfc/rfc3339.txt
see: http://stackoverflow.com/questions/455580/json-datetime-between-python-and-javascript/456032#456032
"""
return dict(key=self.key().name(),
name=self.name,
created_at=self.created_at.strftime('%Y-%m-%dT%H:%M:%S'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment