summaryrefslogtreecommitdiff
path: root/django/utils/timezone.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils/timezone.py')
-rw-r--r--django/utils/timezone.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index cf22ec34d0..bb2b6b9594 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -194,11 +194,7 @@ def now():
"""
Return an aware or naive datetime.datetime, depending on settings.USE_TZ.
"""
- if settings.USE_TZ:
- # timeit shows that datetime.now(tz=utc) is 24% slower
- return datetime.utcnow().replace(tzinfo=utc)
- else:
- return datetime.now()
+ return datetime.now(tz=utc if settings.USE_TZ else None)
# By design, these four functions don't perform any checks on their arguments.