def _match_datetime_pattern(self, tokens):
    "\n        Match the datetime pattern at the beginning of the token list.\n\n        There are several formats that this method needs to understand\n        and distinguish between (see MongoDB's SERVER-7965):\n\n        ctime-pre2.4    Wed Dec 31 19:00:00\n        ctime           Wed Dec 31 19:00:00.000\n        iso8601-utc     1970-01-01T00:00:00.000Z\n        iso8601-local   1969-12-31T19:00:00.000+0500\n        "
    assume_iso8601_format = (len(tokens) < 4)
    if (not assume_iso8601_format):
        (weekday, month, day, time) = tokens[:4]
        if ((len(tokens) < 4) or (weekday not in self.weekdays) or (month not in self.months) or (not day.isdigit())):
            assume_iso8601_format = True
    if assume_iso8601_format:
        if (not re.match('\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}', tokens[0])):
            return None
        dt = dateutil.parser.parse(tokens[0])
        self._datetime_format = ('iso8601-utc' if tokens[0].endswith('Z') else 'iso8601-local')
    else:
        year = datetime.now().year
        dt = dateutil.parser.parse(' '.join(tokens[:4]), default=datetime(year, 1, 1))
        if (dt.tzinfo is None):
            dt = dt.replace(tzinfo=tzutc())
        if (self._year_rollover and (dt > self._year_rollover)):
            dt = dt.replace(year=(year - 1))
        self._datetime_format = ('ctime' if ('.' in tokens[3]) else 'ctime-pre2.4')
    return dt
Match the datetime pattern at the beginning of the token list.

There are several formats that this method needs to understand
and distinguish between (see MongoDB's SERVER-7965):

ctime-pre2.4    Wed Dec 31 19:00:00
ctime           Wed Dec 31 19:00:00.000
iso8601-utc     1970-01-01T00:00:00.000Z
iso8601-local   1969-12-31T19:00:00.000+0500
def _match_datetime_pattern(self, tokens):
    "\n        Match the datetime pattern at the beginning of the token list.\n\n        There are several formats that this method needs to understand\n        and distinguish between (see MongoDB's SERVER-7965):\n\n        ctime-pre2.4    Wed Dec 31 19:00:00\n        ctime           Wed Dec 31 19:00:00.000\n        iso8601-utc     1970-01-01T00:00:00.000Z\n        iso8601-local   1969-12-31T19:00:00.000+0500\n        "
    assume_iso8601_format = (len(tokens) < 4)
    if (not assume_iso8601_format):
        (weekday, month, day, time) = tokens[:4]
        if ((len(tokens) < 4) or (weekday not in self.weekdays) or (month not in self.months) or (not day.isdigit())):
            assume_iso8601_format = True
    if assume_iso8601_format:
        if (not re.match('\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}', tokens[0])):
            return None
        dt = dateutil.parser.parse(tokens[0])
        self._datetime_format = ('iso8601-utc' if tokens[0].endswith('Z') else 'iso8601-local')
    else:
        year = datetime.now().year
        dt = dateutil.parser.parse(' '.join(tokens[:4]), default=datetime(year, 1, 1))
        if (dt.tzinfo is None):
            dt = dt.replace(tzinfo=tzutc())
        if (self._year_rollover and (dt > self._year_rollover)):
            dt = dt.replace(year=(year - 1))
        self._datetime_format = ('ctime' if ('.' in tokens[3]) else 'ctime-pre2.4')
    return dt