from datetime import datetime


def time_diff_close_enough(time1, time2, within_minutes):
    """Test whether two datetimes (TIMESTAMP's) are:
    1. within a specified number of minutes of each other; and
    2. within a specified number (the same number) of minutes of right now.
    If both are true, then they are deemed to be "close enough", on the
    assumption that they were each set to NOW() or CURRENT_TIMESTAMP(), and
    the difference is because VoltDB and its comparison database (HSQL or
    PostgreSQL) called that function at slightly different times.
    """
    time_diff_in_minutes = (time1 - time2).total_seconds() / 60
    if abs(time_diff_in_minutes) > within_minutes:
        return False
    time_diff_in_minutes = (time2 - datetime.now()).total_seconds() / 60
    if abs(time_diff_in_minutes) > within_minutes:
        return False
    return True