Jannis Leidel avatar Jannis Leidel committed fcf464b

Fixed the timezone handling by simply converting the timezone aware datetime object into a naive version with the help of the default timezone (aka settings.TIME_ZONE).

Comments (0)

Files changed (1)

south/modelsinspector.py

     # Make sure Decimal is converted down into a string
     if isinstance(value, decimal.Decimal):
         value = str(value)
+    # in case the value is timezone aware
     if isinstance(value, (datetime.datetime, datetime.time)):
-        value = dumb_down_timezone(value)
+        try:
+            from django.utils import timezone
+        except ImportError:
+            pass
+        else:
+            if (getattr(settings, 'USE_TZ', False) and
+                    value is not None and timezone.is_aware(value)):
+                default_timezone = timezone.get_default_timezone()
+                value = timezone.make_naive(value, default_timezone)
     # 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):
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.