grandfatherson/filters.py
def start(cls, now, number, **options):
        """
        Return the starting datetime: ``number`` of months before ``now``.
        """
        year = now.year
        month = now.month - number + 1
        # Handle negative months
        if month < 0:
            year = year + (month // cls.MONTHS_IN_YEAR)
            month = month % cls.MONTHS_IN_YEAR
        # Handle December
        if month == 0:
            year = year - 1
            month = 12
        return cls.mask(now, **options).replace(year=year, month=month)
def start(cls, now, number, **options):
        """
        Return the starting datetime: ``number`` of months before ``now``.
        """
        year = now.year
        month = now.month - number + 1
        # Handle negative months
        if month < 0:
            year = year + (month // cls.MONTHS_IN_YEAR)
            month = month % cls.MONTHS_IN_YEAR
        # Handle December
        if month == 0:
            year = year - 1
            month = 12
        return cls.mask(now, **options).replace(year=year, month=month)
def start ( cls , now , number , * * options ) : year = now . year month = now . month - number + 1 # Handle negative months if month < 0 : year = year + ( month // cls . MONTHS_IN_YEAR ) month = month % cls . MONTHS_IN_YEAR # Handle December if month == 0 : year = year - 1 month = 12 return cls . mask ( now , * * options ) . replace ( year = year , month = month )
Return the starting datetime: ``number`` of months before ``now``.
Return the starting datetime : number of months before now .