code: def _encodeTimestamp(timestamp):
      
      if timestamp.tzinfo == None:
          raise ValueError('Please specify time zone information for the timestamp (e.g. by using gsmmodem.util.SimpleOffsetTzInfo)')
  
      # See if the timezone difference is positive/negative
      tzDelta = timestamp.utcoffset()
      if tzDelta.days >= 0:
          tzValStr = '{0:0>2}'.format(int(tzDelta.seconds / 60 / 15))
      else: # negative
          tzVal = int((tzDelta.days * -3600 * 24 - tzDelta.seconds) / 60 / 15) # calculate offset in 0.25 hours
          # Cast as literal hex value and set MSB of first semi-octet of timezone to 1 to indicate negative value
          tzVal = int('{0:0>2}'.format(tzVal), 16) | 0x80
          tzValStr = '{0:0>2X}'.format(tzVal)
  
      dateStr = timestamp.strftime('%y%m%d%H%M%S') + tzValStr
  
      return encodeSemiOctets(dateStr)
docs: Encodes a 7-octet timestamp from the specified date
      
      Note: the specified timestamp must have a UTC offset set; you can use gsmmodem.util.SimpleOffsetTzInfo for simple cases
      
      :param timestamp: The timestamp to encode
      :type timestamp: datetime.datetime
      
      :return: The encoded timestamp
      :rtype: bytearray