Added FIXME message in PostMessage32x if parameters are truncated
[wine/multimedia.git] / win32 / time.c
blobfc82034710d51440947162976f14a89bbae56093
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 */
7 #include <string.h>
8 #include <time.h>
9 #include <sys/time.h>
10 #include <unistd.h>
11 #include "file.h"
12 #include "windows.h"
13 #include "winerror.h"
14 #include "debug.h"
16 /***********************************************************************
17 * GetLocalTime (KERNEL32.228)
19 VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
21 time_t local_time;
22 struct tm *local_tm;
23 struct timeval tv;
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)
44 time_t local_time;
45 struct tm *local_tm;
46 struct timeval tv;
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)
68 struct timeval tv;
69 struct timezone tz;
70 struct tm t;
71 time_t sec;
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;
83 sec = mktime (&t);
85 /* set the new time */
86 tv.tv_sec = sec;
87 tv.tv_usec = systime->wMilliseconds * 1000;
88 if (settimeofday(&tv, &tz))
90 return FALSE;
92 else
94 return TRUE;
99 /***********************************************************************
100 * GetTimeZoneInformation (KERNEL32.302)
102 DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
104 time_t gmt, lt;
106 memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
108 gmt = time(NULL);
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)
123 struct timezone tz;
125 tz.tz_minuteswest = tzinfo->Bias;
126 #ifdef DST_NONE
127 tz.tz_dsttime = DST_NONE;
128 #else
129 tz.tz_dsttime = 0;
130 #endif
131 return !settimeofday(NULL, &tz);
135 /***********************************************************************
136 * GetSystemTimeAsFileTime (KERNEL32)
138 VOID WINAPI GetSystemTimeAsFileTime(LPFILETIME systemtimeAsfiletime) {
139 DOSFS_UnixTimeToFileTime(time(NULL),systemtimeAsfiletime,0);