2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
15 /***********************************************************************
16 * GetLocalTime (KERNEL32.228)
18 VOID WINAPI
GetLocalTime(LPSYSTEMTIME systime
)
24 gettimeofday(&tv
, NULL
);
25 local_time
= tv
.tv_sec
;
26 local_tm
= localtime(&local_time
);
28 systime
->wYear
= local_tm
->tm_year
+ 1900;
29 systime
->wMonth
= local_tm
->tm_mon
+ 1;
30 systime
->wDayOfWeek
= local_tm
->tm_wday
;
31 systime
->wDay
= local_tm
->tm_mday
;
32 systime
->wHour
= local_tm
->tm_hour
;
33 systime
->wMinute
= local_tm
->tm_min
;
34 systime
->wSecond
= local_tm
->tm_sec
;
35 systime
->wMilliseconds
= (tv
.tv_usec
/ 1000) % 1000;
38 /***********************************************************************
39 * GetSystemTime (KERNEL32.285)
41 VOID WINAPI
GetSystemTime(LPSYSTEMTIME systime
)
47 gettimeofday(&tv
, NULL
);
48 local_time
= tv
.tv_sec
;
49 local_tm
= gmtime(&local_time
);
51 systime
->wYear
= local_tm
->tm_year
+ 1900;
52 systime
->wMonth
= local_tm
->tm_mon
+ 1;
53 systime
->wDayOfWeek
= local_tm
->tm_wday
;
54 systime
->wDay
= local_tm
->tm_mday
;
55 systime
->wHour
= local_tm
->tm_hour
;
56 systime
->wMinute
= local_tm
->tm_min
;
57 systime
->wSecond
= local_tm
->tm_sec
;
58 systime
->wMilliseconds
= (tv
.tv_usec
/ 1000) % 1000;
62 /***********************************************************************
63 * SetSystemTime (KERNEL32.507)
65 BOOL WINAPI
SetSystemTime(const SYSTEMTIME
*systime
)
72 /* call gettimeofday to get the current timezone */
73 gettimeofday(&tv
, &tz
);
75 /* get the number of seconds */
76 t
.tm_sec
= systime
->wSecond
;
77 t
.tm_min
= systime
->wMinute
;
78 t
.tm_hour
= systime
->wHour
;
79 t
.tm_mday
= systime
->wDay
;
80 t
.tm_mon
= systime
->wMonth
;
81 t
.tm_year
= systime
->wYear
;
84 /* set the new time */
86 tv
.tv_usec
= systime
->wMilliseconds
* 1000;
87 if (settimeofday(&tv
, &tz
))
98 /***********************************************************************
99 * GetTimeZoneInformation (KERNEL32.302)
101 DWORD WINAPI
GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo
)
105 memset(tzinfo
, 0, sizeof(TIME_ZONE_INFORMATION
));
108 lt
= mktime(gmtime(&gmt
));
109 tzinfo
->Bias
= (lt
- gmt
) / 60;
110 tzinfo
->StandardBias
= 0;
111 tzinfo
->DaylightBias
= -60;
113 return TIME_ZONE_ID_UNKNOWN
;
117 /***********************************************************************
118 * SetTimeZoneInformation (KERNEL32.515)
120 BOOL WINAPI
SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION tzinfo
)
124 tz
.tz_minuteswest
= tzinfo
->Bias
;
126 tz
.tz_dsttime
= DST_NONE
;
130 return !settimeofday(NULL
, &tz
);
134 /***********************************************************************
135 * GetSystemTimeAsFileTime (KERNEL32)
137 VOID WINAPI
GetSystemTimeAsFileTime(LPFILETIME systemtimeAsfiletime
) {
138 DOSFS_UnixTimeToFileTime(time(NULL
),systemtimeAsfiletime
,0);
141 /***********************************************************************
142 * SystemTimeToTzSpecificLocalTime32 (KERNEL32.683)
144 BOOL WINAPI
SystemTimeToTzSpecificLocalTime(
145 LPTIME_ZONE_INFORMATION lpTimeZoneInformation
,
146 LPSYSTEMTIME lpUniversalTime
,
147 LPSYSTEMTIME lpLocalTime
) {
149 FIXME(win32
, ":stub\n");
150 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);