Commits

Mikhail Denisenko  committed ed7fba2

fixed django test: test_raw_sql (modeltests.timezones.tests.NewDatabaseTests), support timezone for query parameters.

  • Participants
  • Parent commits 016fc3f

Comments (0)

Files changed (1)

File sqlserver/ado/dbapi.py

             p.Precision = digit_count + exponent
 
     elif isinstance(value, datetime.time):
+            if getattr(settings, 'USE_TZ', False) and value.tzinfo:
+                value = value.astimezone(timezone.utc)
             p.Value = datetime.datetime(1,1,1, value.hour, value.minute, value.second)
+    elif isinstance(value, datetime.datetime):
+            if getattr(settings, 'USE_TZ', False) and value.tzinfo:
+                value = value.astimezone(timezone.utc)
+            p.Value = value
     else:
         # For any other type, set the value and let pythoncom do the right thing.
         p.Value = value