code: def serialize_unix(attr, **kwargs):
          
          if isinstance(attr, int):
              return attr
          try:
              if not attr.tzinfo:
                  _LOGGER.warning(
                      "Datetime with no tzinfo will be considered UTC.")
              return int(calendar.timegm(attr.utctimetuple()))
          except AttributeError:
              raise TypeError("Unix time object must be valid Datetime object.")
docs: Serialize Datetime object into IntTime format.
          This is represented as seconds.
  
          :param Datetime attr: Object to be serialized.
          :rtype: int
          :raises: SerializationError if format invalid