Release 960516
[wine/multimedia.git] / win32 / time.c
blob610d4a6067d513dbf3fe1e13611b073580cbdc26
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 "windows.h"
12 #include "winerror.h"
13 #include "kernel32.h"
14 #include "stddebug.h"
15 #include "debug.h"
17 /***********************************************************************
18 * GetLocalTime (KERNEL32.228)
20 VOID GetLocalTime(LPSYSTEMTIME systime)
22 time_t local_time;
23 struct tm *local_tm;
24 struct timeval tv;
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;
40 /***********************************************************************
41 * GetSystemTime (KERNEL32.285)
43 VOID GetSystemTime(LPSYSTEMTIME systime)
45 time_t local_time;
46 struct tm *local_tm;
47 struct timeval tv;
49 gettimeofday(&tv, NULL);
50 local_time = tv.tv_sec;
51 local_tm = gmtime(&local_time);
53 systime->wYear = local_tm->tm_year + 1900;
54 systime->wMonth = local_tm->tm_mon + 1;
55 systime->wDayOfWeek = local_tm->tm_wday;
56 systime->wDay = local_tm->tm_mday;
57 systime->wHour = local_tm->tm_hour;
58 systime->wMinute = local_tm->tm_min;
59 systime->wSecond = local_tm->tm_sec;
60 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
63 /***********************************************************************
64 * GetTimeZoneInformation (KERNEL32.302)
66 DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
68 time_t gmt, lt;
70 memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
72 gmt = time(NULL);
73 lt = mktime(localtime(&gmt));
74 tzinfo->Bias = (gmt - lt) / 60;
75 tzinfo->StandardBias = 0;
76 tzinfo->DaylightBias = -60;
78 return TIME_ZONE_ID_UNKNOWN;
81 /***********************************************************************
82 * Sleep (KERNEL32.523)
84 VOID Sleep(DWORD cMilliseconds)
86 if(cMilliseconds == INFINITE)
87 while(1) sleep(1000); /* Spin forever */
88 usleep(cMilliseconds*1000);