def find_closest_date(date, list_of_dates, how='abs'):
    """
    Finds the closest date in a provided list.

    Returns the closest date value, either absolutely, or closest without being above/below, and the timedelta from the
    provided date.

    :param datetime date: date from which to find closest match in list
    :param list list_of_dates: list of datetimes
    :param str how: ['abs', 'pos','neg']
            'abs': Absolute closest datetime, either above or below the given date
            'pos': Matched datetime must be greater than given date
            'neg': Matched datetime must be less than given date
    :return tuple: match, delta; the matching date from the list, and it's difference to the original as a timedelta
    """

    list_of_dates[:] = [l for l in list_of_dates if l]  # remove any Nones

    if how == 'abs':
        try:
            match = min(list_of_dates, key=lambda x: abs(x - date))
        except ValueError:
            return None, None
    elif how == 'pos':
        try:
            new_list = [d for d in list_of_dates if d > date]  # filter for only positives first
            match = min(new_list, key=lambda x: (x - date))
        except ValueError:
            return None, None
    elif how == 'neg':
        try:
            new_list = [d for d in list_of_dates if d <= date]  # filter for only negatives first
            match = max(new_list, key=lambda x: x - date)
        except ValueError:
            return None, None
    else:
        assert False, "Supplied 'how' not in ['abs', 'pos', 'neg']"

    delta = match - date

    return match, delta