mirror of
https://github.com/django/django.git
synced 2024-12-24 18:16:19 +00:00
Do [8221] in a slightly more clean way.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8222 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9f6ab8104c
commit
d06b474251
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user