code: def timedelta_to_str(value, with_microseconds=False):
      
      if value is None:
          return None
  
      if not isinstance(value, timedelta):
          raise TypeError('value must be a datetime.timedelta object')
  
      hours, remainder = divmod(value.seconds, SECONDS_IN_HOUR)
      hours += value.days * HOURS_IN_DAY
      minutes, seconds = divmod(remainder, SECONDS_IN_MINUTE)
  
      if with_microseconds:
          return '%02d:%02d:%02d.%06d' % (hours, minutes, seconds,
                                          value.microseconds)
      else:
          return '%02d:%02d:%02d' % (hours, minutes, seconds)
docs: String representation of datetime.timedelta
      :param value: timedelta to convert
      :type value: datetime.timedelta
      :param with_microseconds:
      :type with_microseconds: bool
      :return: String representation of datetime.timedelta or None if val is None
      :rtype: string/None
      :raise: TypeError when val is not timedelta