Commits

Jannis Leidel  committed b88543d

Added support for timezone aware datetime objects as supported in Django 1.4.

  • Participants
  • Parent commits e1867ac

Comments (0)

Files changed (1)

File south/modelsinspector.py

     # Make sure Decimal is converted down into a string
     if isinstance(value, decimal.Decimal):
         value = str(value)
+    if isinstance(value, (datetime.datetime, datetime.time)):
+        value = dumb_down_timezone(value)
     # datetime_safe has an improper repr value
     if isinstance(value, datetime_safe.datetime):
         value = datetime.datetime(*value.utctimetuple()[:7])
     # Return the final value
     return repr(value)
 
+def dumb_down_timezone(value):
+    try:
+        from django.utils import timezone
+    except ImportError:
+        pass
+    else:
+        if settings.USE_TZ and timezone.is_aware(value):
+            value = value.astimezone(timezone.utc).replace(tzinfo=None)
+    return value
+
 
 def introspector(field):
     """