def findNearestDate(date_list, date):
    """
    Find closest datapoint of each uppermost sensor in time window.

    Adapted from https://stackoverflow.com/a/32237949/3816498 .

    Parameters
    ----------
    date_list : array-like
        List of dates
    date : datetime
        The date, to which the nearest date in `items` should be found.

    Returns
    -------
    nearest_date : datetime
        Nearest date to `date` in `date_list`
    time_delta : int
        Time difference in minutes

    """
    nearest_date = min(date_list, key=lambda x: abs(x - date))
    time_delta = (nearest_date - date).total_seconds() / 60.
    return nearest_date, time_delta