os/time: make os_get_localtime more portable

gettimeofday() doesn't exist on Windows, as reported by @equalsraf. It seems
a call to time() would be sufficient here, as only the seconds since the
UNIX epoch are needed.
This commit is contained in:
Nicolas Hillegeer
2014-07-19 14:33:55 +02:00
committed by Justin M. Keyes
parent 8d44e36b1a
commit 6610b002ef

View File

@@ -1,6 +1,6 @@
#include <stdint.h>
#include <stdbool.h>
#include <sys/time.h>
#include <time.h>
#include <uv.h>
@@ -105,10 +105,6 @@ return result;
/// argument) or NULL in case of error
struct tm *os_get_localtime(struct tm *result)
{
struct timeval tv;
if (gettimeofday(&tv, NULL) < 0) {
return NULL;
}
return os_localtime_r(&tv.tv_sec, result);
time_t rawtime = time(NULL);
return os_localtime_r(&rawtime, result);
}