Added sysres_Ru.s
[wine/multimedia.git] / win32 / time.c
blobf3b0fb297adb4d498912cb08ca00b95a3f4c13ce
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 "winerror.h"
13 #include "debug.h"
15 /***********************************************************************
16 * GetLocalTime (KERNEL32.228)
18 VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
20 time_t local_time;
21 struct tm *local_tm;
22 struct timeval tv;
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)
43 time_t local_time;
44 struct tm *local_tm;
45 struct timeval tv;
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)
67 struct timeval tv;
68 struct timezone tz;
69 struct tm t;
70 time_t sec;
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;
82 sec = mktime (&t);
84 /* set the new time */
85 tv.tv_sec = sec;
86 tv.tv_usec = systime->wMilliseconds * 1000;
87 if (settimeofday(&tv, &tz))
89 return FALSE;
91 else
93 return TRUE;
98 /***********************************************************************
99 * GetTimeZoneInformation (KERNEL32.302)
101 DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
103 time_t gmt, lt;
105 memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
107 gmt = time(NULL);
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)
122 struct timezone tz;
124 tz.tz_minuteswest = tzinfo->Bias;
125 #ifdef DST_NONE
126 tz.tz_dsttime = DST_NONE;
127 #else
128 tz.tz_dsttime = 0;
129 #endif
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);
151 return FALSE;