MSVC support: alternative implementation of getTime()

This commit is contained in:
Raymonf 2020-08-19 22:26:46 -04:00
parent 1ec4634f69
commit e75049fc98
2 changed files with 11 additions and 0 deletions

View File

@ -18,7 +18,13 @@ int U8toU16(std::string src, char16_t* des) {
}
uint64_t getTime() {
#ifndef _MSC_VER
struct timeval tp;
gettimeofday(&tp, NULL);
return tp.tv_sec * 1000 + tp.tv_usec / 1000;
#else
time_t t;
time(&t);
return (uint64_t)t;
#endif
}

View File

@ -10,7 +10,12 @@
#include <iostream>
#include <stdio.h>
#include <stdint.h>
// Can't use this in MSVC.
#ifndef _MSC_VER
#include <sys/time.h>
#else
#include <time.h>
#endif
#include <cstring>
#include <string>
#include <locale>