from datetime import datetime


def str2datetime(string: str) -> datetime:
    """Convert string to datetime.date in typical formats."""
    for fmt in ('%Y-%m-%dT%H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S',
                '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M:%S', '%Y%m%d %H:%M:%S', '%d.%m.%Y %H:%M:%S',
                '%Y-%m-%d %H:%M', '%Y%m%d %H:%M', '%d.%m.%Y %H:%M'):
        try:
            return datetime.strptime(string, fmt)
        except ValueError:
            pass
    raise ValueError(f"date {string!r} does not match any format")