from datetime import datetime


def convert_date(date, fmt="%d.%m.%Y"):
    """Convert string date to datetime."""
    if type(date) is datetime:
        return date
    if date:
        return datetime.strptime(date, fmt)
    return None