def make_datetime(time_string, formats=None):
    'Makes datetime from string based on one of the formats.\n\n    :param string time_string: time in string\n    :param list formats: list of accepted formats\n    :return datetime.datetime: datetime or None if no format is matched\n    '
    if (formats is None):
        formats = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d']
    for fmt in formats:
        try:
            return datetime.datetime.strptime(time_string, fmt)
        except ValueError:
            pass
    return None
Makes datetime from string based on one of the formats.

:param string time_string: time in string
:param list formats: list of accepted formats
:return datetime.datetime: datetime or None if no format is matched
def make_datetime(time_string, formats=None):
    'Makes datetime from string based on one of the formats.\n\n    :param string time_string: time in string\n    :param list formats: list of accepted formats\n    :return datetime.datetime: datetime or None if no format is matched\n    '
    if (formats is None):
        formats = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d']
    for fmt in formats:
        try:
            return datetime.datetime.strptime(time_string, fmt)
        except ValueError:
            pass
    return None