Ticket #14711: dates.diff
File dates.diff, 1.6 KB (added by , 14 years ago) |
---|
-
django/views/generic/dates.py
70 70 Get the previous valid month. 71 71 """ 72 72 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)) 74 74 return _get_next_prev_month(self, prev, is_previous=True, use_first_day=True) 75 75 76 76 … … 514 514 This is a bit complicated since it handles both next and previous months 515 515 and days (for MonthArchiveView and DayArchiveView); hence the coupling to generic_view. 516 516 517 However in ess ance the logic comes down to:517 However in essence the logic comes down to: 518 518 519 519 * If allow_empty and allow_future are both true, this is easy: just 520 520 return the naive result (just the next/previous day or month, … … 544 544 # whose date_field is at least (greater than/less than) the given 545 545 # naive result 546 546 else: 547 # Construct a lookup and an ordering depending on w eather we're doing547 # Construct a lookup and an ordering depending on whether we're doing 548 548 # a previous date or a next date lookup. 549 549 if is_previous: 550 550 lookup = {'%s__lte' % date_field: naive_result} … … 567 567 result = result.date() 568 568 569 569 # For month views, we always want to have a date that's the first of the 570 # month for consist ancy's sake.570 # month for consistency's sake. 571 571 if result and use_first_day: 572 572 result = result.replace(day=1) 573 573