Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a stupid bug in the implementation of timezone.make_aware.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17332 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fc9e0606d5333fc1906c85cc7ac3b2020e0b1baa 1 parent b895b29
@aaugustin aaugustin authored
Showing with 28 additions and 1 deletion.
  1. +1 −1  django/utils/timezone.py
  2. +27 −0 tests/modeltests/timezones/tests.py
View
2  django/utils/timezone.py
@@ -267,5 +267,5 @@ def make_naive(value, timezone):
value = value.astimezone(timezone)
if hasattr(timezone, 'normalize'):
# available for pytz time zones
- return timezone.normalize(value)
+ value = timezone.normalize(value)
return value.replace(tzinfo=None)
View
27 tests/modeltests/timezones/tests.py
@@ -953,3 +953,30 @@ def test_change_readonly_in_other_timezone(self):
self.assertContains(response, t.created.astimezone(ICT).isoformat())
AdminTests = override_settings(DATETIME_FORMAT='c', USE_L10N=False, USE_TZ=True)(AdminTests)
+
+
+class UtilitiesTests(BaseDateTimeTests):
+
+ def test_make_aware(self):
+ self.assertEqual(
+ timezone.make_aware(datetime.datetime(2011, 9, 1, 13, 20, 30), EAT),
+ datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
+ )
+ self.assertEqual(
+ timezone.make_aware(datetime.datetime(2011, 9, 1, 10, 20, 30), UTC),
+ datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC)
+ )
+
+ def test_make_naive(self):
+ self.assertEqual(
+ timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), EAT),
+ datetime.datetime(2011, 9, 1, 13, 20, 30)
+ )
+ self.assertEqual(
+ timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), UTC),
+ datetime.datetime(2011, 9, 1, 10, 20, 30)
+ )
+ self.assertEqual(
+ timezone.make_naive(datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC), UTC),
+ datetime.datetime(2011, 9, 1, 10, 20, 30)
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.