code: def parse_datetime(src=None):
      
      if src is None:
          return None
      string = src.replace('"', "")
      # parse timezone ourselves, since %z is not always supported
      # see: http://bugs.python.org/issue6641
      m = UTC_OFFSET_RE.match(string)
      if m:
          sign = 1 if m.group("sign") == "+" else -1
          tz_hours = sign * int(m.group("hours"))
          tz_minutes = sign * int(m.group("minutes"))
          offset = datetime.timedelta(hours=tz_hours, minutes=tz_minutes)
          string = string[:-6]
      else:
          # no explicit timezone
          offset = datetime.timedelta(0)
      if "AM" in string or "PM" in string:
          datetime_obj = datetime.datetime.strptime(string, "%Y-%m-%d %I:%M:%S %p")
      else:
          datetime_obj = datetime.datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
      return datetime_obj + offset
docs: Parse a datetime object from a string.