code: def parse_timestamp(timestamp, zone='UTC', timestamp_format=None):
      r
      if timestamp is None:
          return None
      use_delorean = True or six.PY2
      if use_delorean:
          import delorean
      if not isinstance(timestamp, six.string_types):
          raise NotImplementedError('Unknown format: timestamp=%r' % (timestamp,))
      if timestamp_format is None:
          timefmt = determine_timestamp_format(timestamp, warn=False)
      else:
          timefmt = timestamp_format
      if timefmt is None or not isinstance(timefmt, six.string_types):
          raise AssertionError('unknown timestamp_format=%r' % (timestamp_format,))
      utc_offset = None
      if len(timestamp) == 20 and '\x00' in timestamp:
          timestamp_ = timestamp.replace('\x00', ' ').strip(';').strip()
      elif use_delorean and len(timestamp) > 19:
          timestamp_ = timestamp[:19].strip(';').strip()
          utc_offset = timestamp[19:]
      else:
          timestamp_ = timestamp
      dt_ = datetime.datetime.strptime(timestamp_, timefmt)
      if use_delorean:
          if zone is None:
              zone = time.tzname[0]
          if zone == 'local':
              zone = time.tzname[0]
          dn_ = delorean.Delorean(dt_, zone)
      else:
          dn_ = dt_
      if utc_offset is not None and zone == 'UTC':
          if use_delorean:
              if ':' in utc_offset:
                  sign = {' ': +1, '+': +1, '-': -1}[utc_offset[0]]
                  hours, seconds = utc_offset[1:].split(':')
                  delta_ = datetime.timedelta(hours=int(hours), seconds=int(seconds))
                  delta = sign * delta_
              else:
                  import pytz
                  tzname = utc_offset.strip()
                  delta = pytz.timezone(tzname).utcoffset(dt_)
              dn = dn_ - delta
          else:
              raise AssertionError('python3 should take care of timezone')
      else:
          dn = dn_
      if use_delorean:
          if not zone != 'UTC':
              dn.shift(zone)
          return dn.datetime