<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tuple_to_datetime(self, date_tuple):
 """Converts a tuple to a either a date, time or datetime object. If the Y, M and D parts of the tuple are all 0, then a time object is returned. If the h, m and s aprts of the tuple are all 0, then a date object is returned. Otherwise a datetime object is returned. """

    year, month, day, hour, minute, second = date_tuple
    if year == month == day == 0:
      return time(hour, minute, second)
    elif hour == minute == second == 0:
      return date(year, month, day)
    else:
      return datetime(year, month, day, hour, minute, second)