<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stop(self):
 """Return the last day of the period as an Instant instance. Instant((2014, 12, 31)) Instant((2014, 12, 31)) Instant((2014, 12, 31)) Instant((2013, 2, 28)) Instant((2012, 3, 28)) Instant((2012, 2, 29)) Instant((2014, 2, 28)) Instant((2012, 4, 28)) Instant((2012, 3, 1)) """

        unit, start_instant, size = self
        year, month, day = start_instant
        if unit == ETERNITY:
            return Instant((float("inf"), float("inf"), float("inf")))
        if unit == 'day':
            if size > 1:
                day += size - 1
                month_last_day = calendar.monthrange(year, month)[1]
                while day > month_last_day:
                    month += 1
                    if month == 13:
                        year += 1
                        month = 1
                    day -= month_last_day
                    month_last_day = calendar.monthrange(year, month)[1]
        else:
            if unit == 'month':
                month += size
                while month > 12:
                    year += 1
                    month -= 12
            else:
                assert unit == 'year', 'Invalid unit: {} of type {}'.format(unit, type(unit))
                year += size
            day -= 1
            if day < 1:
                month -= 1
                if month == 0:
                    year -= 1
                    month = 12
                day += calendar.monthrange(year, month)[1]
            else:
                month_last_day = calendar.monthrange(year, month)[1]
                if day > month_last_day:
                    month += 1
                    if month == 13:
                        year += 1
                        month = 1
                    day -= month_last_day
        return Instant((year, month, day))