From d06b474251c979c512a966a7fb41cd8a06487c14 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Tue, 5 Aug 2008 23:53:52 +0000 Subject: [PATCH] Do [8221] in a slightly more clean way. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8222 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/syndication/feeds.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 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() - - # 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: + 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) + + # 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))