Unprotect the resource data in the unhandled exception handler to fix
[wine] / win32 / time.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  *
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.
10  *
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.
15  *
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
19  */
20
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"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(win32);
30
31 /***********************************************************************
32  *              GetLocalTime            (KERNEL32.@)
33  */
34 VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
35 {
36     time_t local_time;
37     struct tm *local_tm;
38     struct timeval tv;
39
40     gettimeofday(&tv, NULL);
41     local_time = tv.tv_sec;
42     local_tm = localtime(&local_time);
43
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;
52 }
53
54 /***********************************************************************
55  *              GetSystemTime            (KERNEL32.@)
56  */
57 VOID WINAPI GetSystemTime(LPSYSTEMTIME systime)
58 {
59     time_t system_time;
60     struct tm *system_tm;
61     struct timeval tv;
62
63     gettimeofday(&tv, NULL);
64     system_time = tv.tv_sec;
65     system_tm = gmtime(&system_time);
66
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;
75 }