blob: 245b51c5a1db0363f5e2e546318069055899861f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*
* localtime.c: localtime implementation for WinCE.
*
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
*
*/
#include "timeutil.h"
struct tm *
localtime(const time_t *timer)
{
SYSTEMTIME ss, ls, s;
FILETIME sf, lf, f;
long long t, diff;
static struct tm tms;
GetSystemTime (&ss);
GetLocalTime (&ls);
SystemTimeToFileTime (&ss, &sf);
SystemTimeToFileTime (&ls, &lf);
diff = __FILETIME_to_ll (&sf) - __FILETIME_to_ll (&lf);
__time_t_to_FILETIME (*timer, &f);
t = __FILETIME_to_ll (&f) - diff;
__ll_to_FILETIME (t, &f);
FileTimeToSystemTime (&f, &s);
__SYSTEMTIME_to_tm (&s, &tms);
return &tms;
}
|