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;
41 /***********************************************************************
42 * SetLocalTime (KERNEL32.655)
44 * FIXME: correct ? Is the timezone param of settimeofday() needed ?
45 * I don't have any docu about SetLocal/SystemTime(), argl...
47 BOOL WINAPI
SetLocalTime(const SYSTEMTIME
*systime
)
53 /* get the number of seconds */
54 t
.tm_sec
= systime
->wSecond
;
55 t
.tm_min
= systime
->wMinute
;
56 t
.tm_hour
= systime
->wHour
;
57 t
.tm_mday
= systime
->wDay
;
58 t
.tm_mon
= systime
->wMonth
;
59 t
.tm_year
= systime
->wYear
;
62 /* set the new time */
64 tv
.tv_usec
= systime
->wMilliseconds
* 1000;
65 return !settimeofday(&tv
, NULL
);
69 /***********************************************************************
70 * GetSystemTime (KERNEL32.285)
72 VOID WINAPI
GetSystemTime(LPSYSTEMTIME systime
)
78 gettimeofday(&tv
, NULL
);
79 local_time
= tv
.tv_sec
;
80 local_tm
= gmtime(&local_time
);
82 systime
->wYear
= local_tm
->tm_year
+ 1900;
83 systime
->wMonth
= local_tm
->tm_mon
+ 1;
84 systime
->wDayOfWeek
= local_tm
->tm_wday
;
85 systime
->wDay
= local_tm
->tm_mday
;
86 systime
->wHour
= local_tm
->tm_hour
;
87 systime
->wMinute
= local_tm
->tm_min
;
88 systime
->wSecond
= local_tm
->tm_sec
;
89 systime
->wMilliseconds
= (tv
.tv_usec
/ 1000) % 1000;
93 /***********************************************************************
94 * SetSystemTime (KERNEL32.507)
96 BOOL WINAPI
SetSystemTime(const SYSTEMTIME
*systime
)
103 /* call gettimeofday to get the current timezone */
104 gettimeofday(&tv
, &tz
);
106 /* get the number of seconds */
107 t
.tm_sec
= systime
->wSecond
;
108 t
.tm_min
= systime
->wMinute
;
109 t
.tm_hour
= systime
->wHour
;
110 t
.tm_mday
= systime
->wDay
;
111 t
.tm_mon
= systime
->wMonth
;
112 t
.tm_year
= systime
->wYear
;
115 /* set the new time */
117 tv
.tv_usec
= systime
->wMilliseconds
* 1000;
118 return !settimeofday(&tv
, &tz
);
122 /***********************************************************************
123 * GetTimeZoneInformation (KERNEL32.302)
125 DWORD WINAPI
GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo
)
131 memset(tzinfo
, 0, sizeof(TIME_ZONE_INFORMATION
));
135 daylight
=ptm
->tm_isdst
;
138 ptm
->tm_isdst
=daylight
;
141 tzinfo
->Bias
= (lt
- gmt
) / 60;
142 tzinfo
->StandardBias
= 0;
143 tzinfo
->DaylightBias
= -60;
145 return TIME_ZONE_ID_UNKNOWN
;
149 /***********************************************************************
150 * SetTimeZoneInformation (KERNEL32.515)
152 BOOL WINAPI
SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION tzinfo
)
156 tz
.tz_minuteswest
= tzinfo
->Bias
;
158 tz
.tz_dsttime
= DST_NONE
;
162 return !settimeofday(NULL
, &tz
);
166 /***********************************************************************
167 * GetSystemTimeAsFileTime (KERNEL32)
169 VOID WINAPI
GetSystemTimeAsFileTime(LPFILETIME systemtimeAsfiletime
) {
170 DOSFS_UnixTimeToFileTime(time(NULL
),systemtimeAsfiletime
,0);
173 /***********************************************************************
174 * SystemTimeToTzSpecificLocalTime32 (KERNEL32.683)
176 BOOL WINAPI
SystemTimeToTzSpecificLocalTime(
177 LPTIME_ZONE_INFORMATION lpTimeZoneInformation
,
178 LPSYSTEMTIME lpUniversalTime
,
179 LPSYSTEMTIME lpLocalTime
) {
182 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);