code: def to_rfc3339(timestamp):
      
      if isinstance(timestamp, datetime.datetime):
          timestamp = timestamp - _EPOCH_START
      if not isinstance(timestamp, datetime.timedelta):
          _logger.error(u'Could not convert %s to a rfc3339 time,', timestamp)
          raise ValueError(u'Invalid timestamp type')
      return strict_rfc3339.timestamp_to_rfc3339_utcoffset(
          timestamp.total_seconds())
docs: Converts ``timestamp`` to an RFC 3339 date string format.
  
      ``timestamp`` can be either a ``datetime.datetime`` or a
      ``datetime.timedelta``.  Instances of the later are assumed to be a delta
      with the beginining of the unix epoch, 1st of January, 1970
  
      The returned string is always Z-normalized.  Examples of the return format:
      '1972-01-01T10:00:20.021Z'
  
      Args:
        timestamp (datetime|timedelta): represents the timestamp to convert
  
      Returns:
        string: timestamp converted to a rfc3339 compliant string as above
  
      Raises:
        ValueError: if timestamp is not a datetime.datetime or datetime.timedelta