code: def find_day_by_offset(year, month, offset):
      
      (_, days_in_month) = calendar.monthrange(year, month)
      if offset >= 0:
          return min(offset, days_in_month)
  
      return max(1, days_in_month + offset + 1)
docs: Get the month day based on date and offset
  
      :param year: date year
      :type year: int
      :param month: date month
      :type month: int
      :param offset: offset in day to compute (usually negative)
      :type offset: int
      :return: day number in the month
      :rtype: int
  
      >>> find_day_by_offset(2015, 7, -1)
      31