from datetime import datetime


def datetime_conv(string, *, format=None):
    """Convert a string to a :class:`datetime.datetime`.

    If ``format=None`` this function uses
    :meth:`datetime.datetime.fromisoformat` else
    :meth:`datetime.datetime.strptime`.

    :param str string: datetime string
    :param format: format string
    :type format: str or None
    :return: converted datetime
    :rtype: datetime.datetime
    :raises ValueError: if the string cannot be converted

    .. versionchanged:: 0.2.0 Renamed (old name: datetime)
    """
    if format is None:
        return datetime.fromisoformat(string)
    else:
        return datetime.strptime(string, format)