code: def asn1_generaltime_to_seconds(timestr):
      
      res = None
      timeformat = "%Y%m%d%H%M%S"
      try:
          res = datetime.strptime(timestr, timeformat + 'Z')
      except ValueError:
          try:
              res = datetime.strptime(timestr, timeformat + '%z')
          except ValueError:
              pass
      return res
docs: The given string has one of the following formats
      YYYYMMDDhhmmssZ
      YYYYMMDDhhmmss+hhmm
      YYYYMMDDhhmmss-hhmm
      @return: a datetime object or None on error