code: def encode(self, val):
          
          # Just copied from original KeePassX source
          y, mon, d, h, min_, s = val.timetuple()[:6]
  
          dw1 = 0x0000FFFF & ((y >> 6) & 0x0000003F)
          dw2 = 0x0000FFFF & ((y & 0x0000003F) << 2 | ((mon >> 2) & 0x00000003))
          dw3 = 0x0000FFFF & (((mon & 0x0000003) << 6) | ((d & 0x0000001F) << 1) \
                  | ((h >> 4) & 0x00000001))
          dw4 = 0x0000FFFF & (((h & 0x0000000F) << 4) | ((min_ >> 2) & 0x0000000F))
          dw5 = 0x0000FFFF & (((min_ & 0x00000003) << 6) | (s & 0x0000003F))
  
          return struct.pack('<5B', dw1, dw2, dw3, dw4, dw5)
docs: Encode the python datetime value into the bytes needed for database format. 
          
          :param val: The datetime object.
          :type val: :class:`datetime.datetime`
          :returns: Bytes for data. 
          :rtype: str