def add_months(self, d, m):
        if m == 0:
            return d
        years = 0
        months = m + d.month
        years = int(months / 12)
        months = int(months % 12)
        if months == 0:
            years -= 1
            months = 12
        try:
            return self.add_years(d, years).replace(month = months)
        except __HOLE__:
            years = 0
            months = m + d.month + 1
            years = int(months / 12)
            months = int(months % 12)
            if months == 0:
                years -= 1
                months = 12
            return self.add_years(d, years).replace(day = 1).replace(month = months) - datetime.timedelta(days = 1)
dataset/ETHPy150Open duydao/Text-Pastry/text_pastry.py/TextPastryDateRangeCommand.add_months