Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #2460 -- JSON serializer now correctly handles datetime objects…

…. Thanks, siniy and jyrki.pulliainen@gmail.com.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3501 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2e598fb5718123a98d23638450496ec5a9e54205 1 parent f6fbdf5
Jacob Kaplan-Moss authored July 31, 2006

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. 6  django/core/serializers/json.py
6  django/core/serializers/json.py
@@ -41,11 +41,11 @@ class DateTimeAwareJSONEncoder(simplejson.JSONEncoder):
41 41
     TIME_FORMAT = "%H:%M:%S"
42 42
     
43 43
     def default(self, o):
44  
-        if isinstance(o, datetime.date):
  44
+        if isinstance(o, datetime.datetime):
  45
+            return o.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT))
  46
+        elif isinstance(o, datetime.date):
45 47
             return o.strftime(self.DATE_FORMAT)
46 48
         elif isinstance(o, datetime.time):
47 49
             return o.strftime(self.TIME_FORMAT)
48  
-        elif isinstance(o, datetime.datetime):
49  
-            return o.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT))
50 50
         else:
51 51
             return super(self, DateTimeAwareJSONEncoder).default(o)

0 notes on commit 2e598fb

Please sign in to comment.
Something went wrong with that request. Please try again.