Django

Code

Changeset 8222

Show
Ignore:
Timestamp:
08/05/08 18:53:52 (4 months ago)
Author:
jacob
Message:

Do [8221] in a slightly more clean way.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/syndication/feeds.py

    r8221 r8222  
    130130 
    131131            pubdate = self.__get_dynamic_attr('item_pubdate', item) 
    132             now = datetime.now() 
    133             utcnow = datetime.utcnow() 
     132            if pubdate: 
     133                now = datetime.now() 
     134                utcnow = datetime.utcnow() 
    134135 
    135             # Must always subtract smaller time from larger time here. 
    136             if utcnow > now: 
    137                 sign = -1 
    138                 tzDifference = (utcnow - now) 
    139             else: 
    140                 sign = 1 
    141                 tzDifference = (now - utcnow) 
     136                # Must always subtract smaller time from larger time here. 
     137                if utcnow > now: 
     138                    sign = -1 
     139                    tzDifference = (utcnow - now) 
     140                else: 
     141                    sign = 1 
     142                    tzDifference = (now - utcnow) 
    142143 
    143             # Round the timezone offset to the nearest half hour. 
    144             if pubdate: 
     144                # Round the timezone offset to the nearest half hour. 
    145145                tzOffsetMinutes = sign * ((tzDifference.seconds / 60 + 15) / 30) * 30 
    146146                tzOffset = timedelta(minutes=tzOffsetMinutes)