summaryrefslogtreecommitdiffstats
path: root/main/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-24 16:19:48 +0200
committerDan McGee <dan@archlinux.org>2012-07-25 02:57:20 +0200
commitc0bf9e20660cfae7ea8994472555bba23398b598 (patch)
tree889351fc02d4930233acf3dace3ececda4833c88 /main/utils.py
parent61b4098c611592d62b40a9ee941976a869dff4fc (diff)
downloadarchweb-c0bf9e20660cfae7ea8994472555bba23398b598.tar.gz
archweb-c0bf9e20660cfae7ea8994472555bba23398b598.tar.xz
Remove custom utc_now() function, use django.utils.timezone.now()
This was around from the time when we handled timezones sanely and Django did not; now that we are on 1.4 we no longer need our own code to handle this. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/utils.py')
-rw-r--r--main/utils.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/main/utils.py b/main/utils.py
index 879abfb..0b6849a 100644
--- a/main/utils.py
+++ b/main/utils.py
@@ -5,10 +5,10 @@ except ImportError:
from datetime import datetime
import hashlib
-from pytz import utc
from django.core.cache import cache
from django.db import connections, router
+from django.utils.timezone import now
CACHE_TIMEOUT = 1800
@@ -94,17 +94,12 @@ def retrieve_latest(sender, latest_by=None):
return None
-def utc_now():
- '''Returns a timezone-aware UTC date representing now.'''
- return datetime.utcnow().replace(tzinfo=utc)
-
-
def set_created_field(sender, **kwargs):
'''This will set the 'created' field on any object to the current UTC time
if it is unset. For use as a pre_save signal handler.'''
obj = kwargs['instance']
if hasattr(obj, 'created') and not obj.created:
- obj.created = utc_now()
+ obj.created = now()
def database_vendor(model, mode='read'):