Merged the two serializer and unserializer functions into one, cleaned
[wine.git] / win32 / time.c
blobed2840cef20466f60970a3889160e55ef223ea81
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <string.h>
22 #include <time.h>
23 #include <sys/time.h>
24 #include <unistd.h>
25 #include "file.h"
26 #include "winerror.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(win32);
31 /***********************************************************************
32 * GetLocalTime (KERNEL32.@)
34 VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
36 time_t local_time;
37 struct tm *local_tm;
38 struct timeval tv;
40 gettimeofday(&tv, NULL);
41 local_time = tv.tv_sec;
42 local_tm = localtime(&local_time);
44 systime->wYear = local_tm->tm_year + 1900;
45 systime->wMonth = local_tm->tm_mon + 1;
46 systime->wDayOfWeek = local_tm->tm_wday;
47 systime->wDay = local_tm->tm_mday;
48 systime->wHour = local_tm->tm_hour;
49 systime->wMinute = local_tm->tm_min;
50 systime->wSecond = local_tm->tm_sec;
51 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
54 /***********************************************************************
55 * GetSystemTime (KERNEL32.@)
57 VOID WINAPI GetSystemTime(LPSYSTEMTIME systime)
59 time_t system_time;
60 struct tm *system_tm;
61 struct timeval tv;
63 gettimeofday(&tv, NULL);
64 system_time = tv.tv_sec;
65 system_tm = gmtime(&system_time);
67 systime->wYear = system_tm->tm_year + 1900;
68 systime->wMonth = system_tm->tm_mon + 1;
69 systime->wDayOfWeek = system_tm->tm_wday;
70 systime->wDay = system_tm->tm_mday;
71 systime->wHour = system_tm->tm_hour;
72 systime->wMinute = system_tm->tm_min;
73 systime->wSecond = system_tm->tm_sec;
74 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;