2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(win32)
17 /***********************************************************************
18 * GetLocalTime (KERNEL32.228)
20 VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
26 gettimeofday(&tv, NULL);
27 local_time = tv.tv_sec;
28 local_tm = localtime(&local_time);
30 systime->wYear = local_tm->tm_year + 1900;
31 systime->wMonth = local_tm->tm_mon + 1;
32 systime->wDayOfWeek = local_tm->tm_wday;
33 systime->wDay = local_tm->tm_mday;
34 systime->wHour = local_tm->tm_hour;
35 systime->wMinute = local_tm->tm_min;
36 systime->wSecond = local_tm->tm_sec;
37 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
40 /***********************************************************************
41 * GetSystemTime (KERNEL32.285)
43 VOID WINAPI GetSystemTime(LPSYSTEMTIME systime)
49 gettimeofday(&tv, NULL);
50 local_time = tv.tv_sec;
51 local_tm = gmtime(&local_time);
53 systime->wYear = local_tm->tm_year + 1900;
54 systime->wMonth = local_tm->tm_mon + 1;
55 systime->wDayOfWeek = local_tm->tm_wday;
56 systime->wDay = local_tm->tm_mday;
57 systime->wHour = local_tm->tm_hour;
58 systime->wMinute = local_tm->tm_min;
59 systime->wSecond = local_tm->tm_sec;
60 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
64 /***********************************************************************
65 * SetSystemTime (KERNEL32.507)
67 BOOL WINAPI SetSystemTime(const SYSTEMTIME *systime)
74 /* call gettimeofday to get the current timezone */
75 gettimeofday(&tv, &tz);
77 /* get the number of seconds */
78 t.tm_sec = systime->wSecond;
79 t.tm_min = systime->wMinute;
80 t.tm_hour = systime->wHour;
81 t.tm_mday = systime->wDay;
82 t.tm_mon = systime->wMonth;
83 t.tm_year = systime->wYear;
86 /* set the new time */
88 tv.tv_usec = systime->wMilliseconds * 1000;
89 if (settimeofday(&tv, &tz))
100 /***********************************************************************
101 * GetTimeZoneInformation (KERNEL32.302)
103 DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
109 memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
113 daylight=ptm->tm_isdst;
116 ptm->tm_isdst=daylight;
119 tzinfo->Bias = (lt - gmt) / 60;
120 tzinfo->StandardBias = 0;
121 tzinfo->DaylightBias = -60;
123 return TIME_ZONE_ID_UNKNOWN;
127 /***********************************************************************
128 * SetTimeZoneInformation (KERNEL32.515)
130 BOOL WINAPI SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION tzinfo)
134 tz.tz_minuteswest = tzinfo->Bias;
136 tz.tz_dsttime = DST_NONE;
140 return !settimeofday(NULL, &tz);
144 /***********************************************************************
145 * GetSystemTimeAsFileTime (KERNEL32)
147 VOID WINAPI GetSystemTimeAsFileTime(LPFILETIME systemtimeAsfiletime) {
148 DOSFS_UnixTimeToFileTime(time(NULL),systemtimeAsfiletime,0);
151 /***********************************************************************
152 * SystemTimeToTzSpecificLocalTime32 (KERNEL32.683)
154 BOOL WINAPI SystemTimeToTzSpecificLocalTime(
155 LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
156 LPSYSTEMTIME lpUniversalTime,
157 LPSYSTEMTIME lpLocalTime) {
160 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);