summaryrefslogtreecommitdiffstats
path: root/sitemaps.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-23 19:29:40 -0500
committerDan McGee <dan@archlinux.org>2012-03-23 19:54:40 -0500
commit90e08b4863dfaecafee5b151478bda4513b12e85 (patch)
treed25065edd39e1357ea0fd8b24ea86ce5630a8fb6 /sitemaps.py
parentbc1ba4e95a3e572779eb8ba8a947e8d3ce165845 (diff)
downloadarchweb-90e08b4863dfaecafee5b151478bda4513b12e85.tar.gz
archweb-90e08b4863dfaecafee5b151478bda4513b12e85.zip
Make all datetime objects fully timezone aware
This is most of the transition to Django 1.4 `USE_TZ = True`. We need to ensure we don't mix aware and non-aware datetime objects when dealing with datetimes in the code. Add a utc_now() helper method that we can use most places, and ensure there is always a timezone attached when necessary. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'sitemaps.py')
-rw-r--r--sitemaps.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sitemaps.py b/sitemaps.py
index 177555ff..8e9ba36f 100644
--- a/sitemaps.py
+++ b/sitemaps.py
@@ -1,4 +1,5 @@
from datetime import datetime, timedelta
+from pytz import utc
from django.contrib.sitemaps import Sitemap
from django.core.urlresolvers import reverse
@@ -62,7 +63,7 @@ class NewsSitemap(Sitemap):
priority = "0.8"
def __init__(self):
- now = datetime.utcnow()
+ now = datetime.utcnow().replace(tzinfo=utc)
self.one_day_ago = now - timedelta(days=1)
self.one_week_ago = now - timedelta(days=7)