docs: def serialize_iso(attr, **kwargs):
          """Serialize Datetime object into ISO-8601 formatted string.
  
          :param Datetime attr: Object to be serialized.
          :rtype: str
          :raises: SerializationError if format invalid.
          """
          if isinstance(attr, str):
              attr = isodate.parse_datetime(attr)
          try:
              if not attr.tzinfo:
                  _LOGGER.warning(
                      "Datetime with no tzinfo will be considered UTC.")
              utc = attr.utctimetuple()
              if utc.tm_year > 9999 or utc.tm_year < 1:
                  raise OverflowError("Hit max or min date")
  
              microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0')
              if microseconds:
                  microseconds = '.'+microseconds
              date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format(
                  utc.tm_year, utc.tm_mon, utc.tm_mday,
                  utc.tm_hour, utc.tm_min, utc.tm_sec)
              return date + microseconds + 'Z'
          except (ValueError, OverflowError) as err:
              msg = "Unable to serialize datetime object."
              raise_with_traceback(SerializationError, msg, err)
          except AttributeError as err:
              msg = "ISO-8601 object must be valid Datetime object."
              raise_with_traceback(TypeError, msg, err)