def _parse_common(text, **options):
    """
    Tries to parse the string as a common datetime format.

    :param text: The string to parse.
    :type text: str

    :rtype: dict or None
    """
    m = COMMON.match(text)
    has_date = False
    year = 0
    month = 1
    day = 1

    if not m:
        raise ParserError("Invalid datetime string")

    if m.group("date"):
        # A date has been specified
        has_date = True

        year = int(m.group("year"))

        if not m.group("monthday"):
            # No month and day
            month = 1
            day = 1
        else:
            if options["day_first"]:
                month = int(m.group("day"))
                day = int(m.group("month"))
            else:
                month = int(m.group("month"))
                day = int(m.group("day"))

    if not m.group("time"):
        return date(year, month, day)

    # Grabbing hh:mm:ss
    hour = int(m.group("hour"))

    minute = int(m.group("minute"))

    if m.group("second"):
        second = int(m.group("second"))
    else:
        second = 0

    # Grabbing subseconds, if any
    microsecond = 0
    if m.group("subsecondsection"):
        # Limiting to 6 chars
        subsecond = m.group("subsecond")[:6]

        microsecond = int("{:0<6}".format(subsecond))

    if has_date:
        return datetime(year, month, day, hour, minute, second, microsecond)

    return time(hour, minute, second, microsecond)
def _parse_common ( text , ** options ) : m = COMMON . match ( text ) has_date = False year = 0 month = 1 day = 1 if not m : raise ParserError ( "Invalid datetime string" ) if m . group ( "date" ) : has_date = True year = int ( m . group ( "year" ) ) if not m . group ( "monthday" ) : month = 1 day = 1 else : if options [ "day_first" ] : month = int ( m . group ( "day" ) ) day = int ( m . group ( "month" ) ) else : month = int ( m . group ( "month" ) ) day = int ( m . group ( "day" ) ) if not m . group ( "time" ) : return date ( year , month , day ) hour = int ( m . group ( "hour" ) ) minute = int ( m . group ( "minute" ) ) if m . group ( "second" ) : second = int ( m . group ( "second" ) ) else : second = 0 microsecond = 0 if m . group ( "subsecondsection" ) : subsecond = m . group ( "subsecond" ) [ : 6 ] microsecond = int ( "{:0<6}" . format ( subsecond ) ) if has_date : return datetime ( year , month , day , hour , minute , second , microsecond ) return time ( hour , minute , second , microsecond )
Tries to parse the string as a common datetime format.

    :param text: The string to parse.
    :type text: str

    :rtype: dict or None