Add missing headers and call time(0) only on Windows