Django

Code

Changeset 1571

Show
Ignore:
Timestamp:
12/08/05 19:55:53 (3 years ago)
Author:
adrian
Message:

Fixed #992 -- Fixed bug in archive_month generic view leaving out the last day of the month. Thanks, ubernostrum

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/views/generic/date_based.py

    r1510 r1571  
    109109    # Calculate first and last day of month, for use in a date-range lookup. 
    110110    first_day = date.replace(day=1) 
    111     last_day = date 
    112     for i in (31, 30, 29, 28): 
    113         try: 
    114             last_day = last_day.replace(day=i) 
    115         except ValueError: 
    116             continue 
    117         else: 
    118             break 
     111    if first_day.month == 12: 
     112        last_day = first_day.replace(year=first_day.year + 1, month=1) 
     113    else: 
     114        last_day = first_day.replace(month=first_day.month + 1) 
    119115    lookup_kwargs = {'%s__range' % date_field: (first_day, last_day)} 
    120116    # Only bother to check current date if the month isn't in the past.