from datetime import datetime


def _process_custom_date(datetime_value: str, date_format: str) -> str:
    """
    Processes a datetime provided in custom format

    Parameters
    ----------
    datetime_value : str
        Custom Datetime value
    date_format : str
        Format of custom Datetime

    Returns
    -------
    datetime_value : str
        Datetime value as str
    """
    if not isinstance(datetime_value, str):
        raise TypeError(
            f"Date {datetime_value} is of type {type(datetime_value)} must be of type 'str' "
            f"when specifying a custom date format. "
        )

    try:
        datetime_value = datetime.strptime(datetime_value, date_format).isoformat()
    except ValueError:
        raise ValueError(
            f"The date format provided {date_format} was not recognised in the"
            f" datetime provided: {datetime_value}"
        )

    return datetime_value