Ticket #14711: dates.diff

File dates.diff, 1.6 KB (added by Mark Sundstrom, 14 years ago)

Patch for dates.py

  • django/views/generic/dates.py

     
    7070        Get the previous valid month.
    7171        """
    7272        first_day, last_day = _month_bounds(date)
    73         prev = (first_day - datetime.timedelta(days=1)).replace(day=1)
     73        prev = (first_day - datetime.timedelta(days=1))
    7474        return _get_next_prev_month(self, prev, is_previous=True, use_first_day=True)
    7575
    7676
     
    514514    This is a bit complicated since it handles both next and previous months
    515515    and days (for MonthArchiveView and DayArchiveView); hence the coupling to generic_view.
    516516
    517     However in essance the logic comes down to:
     517    However in essence the logic comes down to:
    518518
    519519        * If allow_empty and allow_future are both true, this is easy: just
    520520          return the naive result (just the next/previous day or month,
     
    544544    # whose date_field is at least (greater than/less than) the given
    545545    # naive result
    546546    else:
    547         # Construct a lookup and an ordering depending on weather we're doing
     547        # Construct a lookup and an ordering depending on whether we're doing
    548548        # a previous date or a next date lookup.
    549549        if is_previous:
    550550            lookup = {'%s__lte' % date_field: naive_result}
     
    567567        result = result.date()
    568568
    569569    # For month views, we always want to have a date that's the first of the
    570     # month for consistancy's sake.
     570    # month for consistency's sake.
    571571    if result and use_first_day:
    572572        result = result.replace(day=1)
    573573
Back to Top