1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/wince/time.cpp
3 // Purpose: Implements missing time functionality for WinCE
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
21 #pragma implementation "window.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/msw/winundef.h"
36 #include "wx/msw/wince/time.h"
40 // Hint: use GetSystemTime()
42 struct tm
* __cdecl
localtime(const time_t *)
47 // Possible implementation
49 // Localtime for WinCE
50 // By martin brown (mpatalberta@yahoo.com)
51 // This is really stupid, converting FILETIME to timeval back and
52 // forth. It assumes FILETIME and DWORDLONG are the same structure
55 TIME_ZONE_INFORMATION pTz
;
57 const unsigned short int __mon_yday
[2][13] =
60 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
62 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
66 ULARGE_INTEGER _100ns
;
67 ::GetTimeZoneInformation(&pTz
);
70 _100ns
.QuadPart
= (DWORDLONG
) *t
* 10000 * 1000 /* + ACE_Time_Value::FILETIME_to_timval_skew */;
72 file_time
.dwLowDateTime
= _100ns
.LowPart
;
73 file_time
.dwHighDateTime
= _100ns
.HighPart
;
77 FileTimeToLocalFileTime (&file_time
, &localtime
);
78 FileTimeToSystemTime (&localtime
, &systime
);
80 res
->tm_hour
= systime
.wHour
;
82 if(pTz
.DaylightBias
!=0)
92 iLeap
= (res
->tm_year
% 4 == 0 && (res
->tm_year
% 100 != 0 || res
->tm_year
% 400 == 0));
93 // based on leap select which group to use
95 res
->tm_mday
= systime
.wDay
;
96 res
->tm_min
= systime
.wMinute
;
97 res
->tm_mon
= systime
.wMonth
;
98 res
->tm_sec
= systime
.wSecond
;
99 res
->tm_wday
= systime
.wDayOfWeek
;
100 res
->tm_yday
= __mon_yday
[iLeap
][systime
.wMonth
] + systime
.wDay
;
101 res
->tm_year
= systime
.wYear
;// this the correct year but bias the value to start at the 1900
102 res
->tm_year
= res
->tm_year
- 1900;
108 time_t __cdecl
time(time_t *)
114 size_t __cdecl
wcsftime(wchar_t *, size_t, const wchar_t *,
121 time_t __cdecl
mktime(struct tm
*)
127 struct tm
* __cdecl
gmtime(const time_t *)