From 5910c6810166a8a670b1c566fe0a9227ddfcc87f Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Wed, 4 Aug 1999 14:32:03 +0000 Subject: [PATCH] Implemented SetLocalTime. --- relay32/kernel32.spec | 2 +- win32/time.c | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/relay32/kernel32.spec b/relay32/kernel32.spec index 1a89647e99c..c0192781b98 100644 --- a/relay32/kernel32.spec +++ b/relay32/kernel32.spec @@ -671,7 +671,7 @@ import ntdll.dll 652 stdcall SetHandleCount(long) SetHandleCount 653 stdcall SetHandleInformation(long long long) SetHandleInformation 654 stdcall SetLastError(long) SetLastError -655 stub SetLocalTime +655 stdcall SetLocalTime(ptr) SetLocalTime 656 stdcall SetLocaleInfoA(long long str) SetLocaleInfoA 657 stub SetLocaleInfoW 658 stub SetMailslotInfo diff --git a/win32/time.c b/win32/time.c index f89ba8295c9..0e546dca55c 100644 --- a/win32/time.c +++ b/win32/time.c @@ -37,6 +37,35 @@ VOID WINAPI GetLocalTime(LPSYSTEMTIME systime) systime->wMilliseconds = (tv.tv_usec / 1000) % 1000; } + +/*********************************************************************** + * SetLocalTime (KERNEL32.655) + * + * FIXME: correct ? Is the timezone param of settimeofday() needed ? + * I don't have any docu about SetLocal/SystemTime(), argl... + */ +VOID WINAPI SetLocalTime(LPSYSTEMTIME systime) +{ + struct timeval tv; + struct tm t; + time_t sec; + + /* get the number of seconds */ + t.tm_sec = systime->wSecond; + t.tm_min = systime->wMinute; + t.tm_hour = systime->wHour; + t.tm_mday = systime->wDay; + t.tm_mon = systime->wMonth; + t.tm_year = systime->wYear; + sec = mktime (&t); + + /* set the new time */ + tv.tv_sec = sec; + tv.tv_usec = systime->wMilliseconds * 1000; + return !settimeofday(&tv, NULL); +} + + /*********************************************************************** * GetSystemTime (KERNEL32.285) */ @@ -86,14 +115,7 @@ BOOL WINAPI SetSystemTime(const SYSTEMTIME *systime) /* set the new time */ tv.tv_sec = sec; tv.tv_usec = systime->wMilliseconds * 1000; - if (settimeofday(&tv, &tz)) - { - return FALSE; - } - else - { - return TRUE; - } + return !settimeofday(&tv, &tz); }