From 6610b002ef6068c4a7d4bdec3bd87d61fb934e71 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sat, 19 Jul 2014 14:33:55 +0200 Subject: [PATCH] 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. --- src/nvim/os/time.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 00ffccfaa8..813cb073cf 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include @@ -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); }