mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 08:28:34 +00:00
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:

committed by
Justin M. Keyes

parent
8d44e36b1a
commit
6610b002ef
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
@@ -105,10 +105,6 @@ return result;
|
|||||||
/// argument) or NULL in case of error
|
/// argument) or NULL in case of error
|
||||||
struct tm *os_get_localtime(struct tm *result)
|
struct tm *os_get_localtime(struct tm *result)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
time_t rawtime = time(NULL);
|
||||||
if (gettimeofday(&tv, NULL) < 0) {
|
return os_localtime_r(&rawtime, result);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return os_localtime_r(&tv.tv_sec, result);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user