Created
April 6, 2010 23:55
-
-
Save kamawanu/358287 to your computer and use it in GitHub Desktop.
simlpejson modification, datetime support.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import datetime | |
from django.utils import simplejson | |
def jsondefault(self, data): | |
#### logging.warn( data ) | |
if isinstance(data , datetime.date ): | |
data = data.strftime("%Y-%m-%d") | |
if isinstance(data , datetime.datetime ): | |
data = data.strftime("%Y-%m-%d %H:%i") | |
return data | |
simplejson.JSONEncoder.default = jsondefault |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment