Skip to content

Instantly share code, notes, and snippets.

@kamawanu
Created April 6, 2010 23:55
Show Gist options
  • Save kamawanu/358287 to your computer and use it in GitHub Desktop.
Save kamawanu/358287 to your computer and use it in GitHub Desktop.
simlpejson modification, datetime support.
#!/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