summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-08-05 23:53:52 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-08-05 23:53:52 +0000
commitd06b474251c979c512a966a7fb41cd8a06487c14 (patch)
treeb8f91b7595fcd54be51dc026005ee1d0f8af8872
parent9f6ab8104c72d4b8f56ecc8280606cae959ae126 (diff)
Do [8221] in a slightly more clean way.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8222 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/syndication/feeds.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py
index 933361d233..d0e8ac9db7 100644
--- a/django/contrib/syndication/feeds.py
+++ b/django/contrib/syndication/feeds.py
@@ -129,19 +129,19 @@ class Feed(object):
author_email = author_link = None
pubdate = self.__get_dynamic_attr('item_pubdate', item)
- now = datetime.now()
- utcnow = datetime.utcnow()
+ if pubdate:
+ now = datetime.now()
+ utcnow = datetime.utcnow()
- # Must always subtract smaller time from larger time here.
- if utcnow > now:
- sign = -1
- tzDifference = (utcnow - now)
- else:
- sign = 1
- tzDifference = (now - utcnow)
+ # Must always subtract smaller time from larger time here.
+ if utcnow > now:
+ sign = -1
+ tzDifference = (utcnow - now)
+ else:
+ sign = 1
+ tzDifference = (now - utcnow)
- # Round the timezone offset to the nearest half hour.
- if pubdate:
+ # Round the timezone offset to the nearest half hour.
tzOffsetMinutes = sign * ((tzDifference.seconds / 60 + 15) / 30) * 30
tzOffset = timedelta(minutes=tzOffsetMinutes)
pubdate = pubdate.replace(tzinfo=FixedOffset(tzOffset))