Changeset 1913

Show
Ignore:
Timestamp:
02/01/07 00:29:19 (2 years ago)
Author:
pacopablo
Message:

TracBlogPlugin:

  • Closes #1060
  • Fixed similar bug when passing in an arbitrary day. If it's too big (ie, 32) it will just default to the last day of the month.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tracblogplugin/0.10/blog/web_ui.py

    r1846 r1913  
    5858        return val.strip().lower() in BOOLS_TRUE 
    5959    return None 
     60 
     61def date_crop(year, month, day): 
     62    """Makes sure that the day passed in is avalid for the month and 
     63       year""" 
     64    _, numdays = calendar.monthrange(year, month) 
     65    return (day <= numdays) and day or numdays 
    6066 
    6167 
     
    380386                now.month 
    381387        day = self._choose_value('day', req, None, convert=int) or \ 
    382               now.day  
     388              now.day 
     389        day = date_crop(year, month, day) 
    383390        baseday = datetime.datetime(year, month, day) 
    384391        week_day = self.env.config.get('blog', 'first_week_day', 'SUNDAY') 
     
    540547            if month: 
    541548                year = year or now.year 
    542             days_in_month = calendar.monthrange(year, month or 12)[1] 
    543             start = datetime.datetime(year, month or 12,  
    544                                       day or days_in_month) 
     549            day = date_crop(year, month or 12, day or 1) 
     550            start = datetime.datetime(year, month or 12, day) 
    545551            start += oneday 
    546             end = datetime.datetime(year, month or 1, day or 1
     552            end = datetime.datetime(year, month or 1, day
    547553            start = time.mktime(start.timetuple()) 
    548554            end = time.mktime(end.timetuple())