From b7a2eecaa145398ed177f726379a8b0de58f24ca Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 22 Apr 2025 21:01:54 +0200 Subject: [PATCH] [winpr,sysinfo] use a single clock to provide System and Local time ... rather than a different one for second and sub-second part --- winpr/libwinpr/sysinfo/sysinfo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c index 4c3eaaad8..fd918cb54 100644 --- a/winpr/libwinpr/sysinfo/sysinfo.c +++ b/winpr/libwinpr/sysinfo/sysinfo.c @@ -248,8 +248,9 @@ void GetSystemTime(LPSYSTEMTIME lpSystemTime) struct tm tres; struct tm* stm = NULL; WORD wMilliseconds = 0; - ct = time(NULL); - wMilliseconds = (WORD)(GetTickCount() % 1000); + UINT64 now = winpr_GetUnixTimeNS(); + ct = WINPR_TIME_NS_TO_S(now); + wMilliseconds = (WORD)(WINPR_TIME_NS_REM_MS(now)); stm = gmtime_r(&ct, &tres); ZeroMemory(lpSystemTime, sizeof(SYSTEMTIME)); @@ -279,8 +280,9 @@ VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) struct tm tres; struct tm* ltm = NULL; WORD wMilliseconds = 0; - ct = time(NULL); - wMilliseconds = (WORD)(GetTickCount() % 1000); + UINT64 now = winpr_GetUnixTimeNS(); + ct = WINPR_TIME_NS_TO_S(now); + wMilliseconds = (WORD)(WINPR_TIME_NS_REM_MS(now)); ltm = localtime_r(&ct, &tres); ZeroMemory(lpSystemTime, sizeof(SYSTEMTIME));