Junio C Hamano schrieb: > Johannes Sixt <j.sixt@xxxxxxxxxxxxx> writes: >> This one is used from compat/mingw.c for the gettimeofday emulation. >> Please leave it extern. I'll add this patch to may windows-update series to avoids this hack. --- 8< --- From: Johannes Sixt <j6t@xxxxxxxx> Subject: [PATCH] compat/mingw.c: do not use tm_to_time_t from date.c To implement gettimeofday(), a broken-down UTC time was requested from the system using GetSystemTime() and converted using tm_to_time_t() because it does not look at the current timezone, which mktime() would do. But meanwhile we have grown infrastructure in mingw.c, so that we can use a different conversion path. This way we can avoid the ugly back-reference from the compatibility layer to the generic git code. Signed-off-by: Johannes Sixt <j6t@xxxxxxxx> --- compat/mingw.c | 18 +++++------------- 1 files changed, 5 insertions(+), 13 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index faaaade..3c78f39 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -281,19 +281,11 @@ int mkstemp(char *template) int gettimeofday(struct timeval *tv, void *tz) { - SYSTEMTIME st; - struct tm tm; - GetSystemTime(&st); - tm.tm_year = st.wYear-1900; - tm.tm_mon = st.wMonth-1; - tm.tm_mday = st.wDay; - tm.tm_hour = st.wHour; - tm.tm_min = st.wMinute; - tm.tm_sec = st.wSecond; - tv->tv_sec = tm_to_time_t(&tm); - if (tv->tv_sec < 0) - return -1; - tv->tv_usec = st.wMilliseconds*1000; + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + tv->tv_sec = filetime_to_time_t(&ft); + /* the unit is 100-nanoseconds, ie., a 10th of a microsecond */ + tv->tv_usec = (ft.dwLowDateTime % 10000000) / 10; return 0; } -- 1.6.6.1207.g714a1.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html