C++ calculates the function and call instance of any two-day interval