2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
16 /***********************************************************************
17 * GetLocalTime (KERNEL32.228)
19 VOID WINAPI
GetLocalTime(LPSYSTEMTIME systime
)
25 gettimeofday(&tv
, NULL
);
26 local_time
= tv
.tv_sec
;
27 local_tm
= localtime(&local_time
);
29 systime
->wYear
= local_tm
->tm_year
+ 1900;
30 systime
->wMonth
= local_tm
->tm_mon
+ 1;
31 systime
->wDayOfWeek
= local_tm
->tm_wday
;
32 systime
->wDay
= local_tm
->tm_mday
;
33 systime
->wHour
= local_tm
->tm_hour
;
34 systime
->wMinute
= local_tm
->tm_min
;
35 systime
->wSecond
= local_tm
->tm_sec
;
36 systime
->wMilliseconds
= (tv
.tv_usec
/ 1000) % 1000;
39 /***********************************************************************
40 * GetSystemTime (KERNEL32.285)
42 VOID WINAPI
GetSystemTime(LPSYSTEMTIME systime
)
48 gettimeofday(&tv
, NULL
);
49 local_time
= tv
.tv_sec
;
50 local_tm
= gmtime(&local_time
);
52 systime
->wYear
= local_tm
->tm_year
+ 1900;
53 systime
->wMonth
= local_tm
->tm_mon
+ 1;
54 systime
->wDayOfWeek
= local_tm
->tm_wday
;
55 systime
->wDay
= local_tm
->tm_mday
;
56 systime
->wHour
= local_tm
->tm_hour
;
57 systime
->wMinute
= local_tm
->tm_min
;
58 systime
->wSecond
= local_tm
->tm_sec
;
59 systime
->wMilliseconds
= (tv
.tv_usec
/ 1000) % 1000;
63 /***********************************************************************
64 * SetSystemTime (KERNEL32.507)
66 BOOL32 WINAPI
SetSystemTime(const SYSTEMTIME
*systime
)
73 /* call gettimeofday to get the current timezone */
74 gettimeofday(&tv
, &tz
);
76 /* get the number of seconds */
77 t
.tm_sec
= systime
->wSecond
;
78 t
.tm_min
= systime
->wMinute
;
79 t
.tm_hour
= systime
->wHour
;
80 t
.tm_mday
= systime
->wDay
;
81 t
.tm_mon
= systime
->wMonth
;
82 t
.tm_year
= systime
->wYear
;
85 /* set the new time */
87 tv
.tv_usec
= systime
->wMilliseconds
* 1000;
88 if (settimeofday(&tv
, &tz
))
99 /***********************************************************************
100 * GetTimeZoneInformation (KERNEL32.302)
102 DWORD WINAPI
GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo
)
106 memset(tzinfo
, 0, sizeof(TIME_ZONE_INFORMATION
));
109 lt
= mktime(localtime(&gmt
));
110 tzinfo
->Bias
= (gmt
- lt
) / 60;
111 tzinfo
->StandardBias
= 0;
112 tzinfo
->DaylightBias
= -60;
114 return TIME_ZONE_ID_UNKNOWN
;
118 /***********************************************************************
119 * SetTimeZoneInformation (KERNEL32.515)
121 BOOL32 WINAPI
SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION tzinfo
)
125 tz
.tz_minuteswest
= tzinfo
->Bias
;
127 tz
.tz_dsttime
= DST_NONE
;
131 return !settimeofday(NULL
, &tz
);
135 /***********************************************************************
136 * GetSystemTimeAsFileTime (KERNEL32)
138 VOID WINAPI
GetSystemTimeAsFileTime(LPFILETIME systemtimeAsfiletime
) {
139 DOSFS_UnixTimeToFileTime(time(NULL
),systemtimeAsfiletime
,0);