Replace `HAVE_GETTIMEOFDAY` with `_MSC_VER`. Assuming it everywhere
except on MSVC. On MSVC, fill in the missing function with a local
implementation copied from `src/misc.c`.
To improve building standalone by reducing the reliance on autotools,
cmake configure. Also to bring MSVC builds to the same functionality as
other platforms.
Cherry-picked from #2485Closes#2491