Instantly share code, notes, and snippets.

Embed
What would you like to do?
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