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 // ---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "window.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/msw/wrapwin.h"
35 #include "wx/msw/wince/time.h"
39 // Hint: use GetSystemTime()
41 struct tm
* __cdecl
localtime(const time_t *)
46 // Possible implementation
48 // Localtime for WinCE
49 // By martin brown (mpatalberta@yahoo.com)
50 // This is really stupid, converting FILETIME to timeval back and
51 // forth. It assumes FILETIME and DWORDLONG are the same structure
54 TIME_ZONE_INFORMATION pTz
;
56 const unsigned short int __mon_yday
[2][13] =
59 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
61 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
65 ULARGE_INTEGER _100ns
;
66 ::GetTimeZoneInformation(&pTz
);
69 _100ns
.QuadPart
= (DWORDLONG
) *t
* 10000 * 1000 /* + ACE_Time_Value::FILETIME_to_timval_skew */;
71 file_time
.dwLowDateTime
= _100ns
.LowPart
;
72 file_time
.dwHighDateTime
= _100ns
.HighPart
;
76 FileTimeToLocalFileTime (&file_time
, &localtime
);
77 FileTimeToSystemTime (&localtime
, &systime
);
79 res
->tm_hour
= systime
.wHour
;
81 if(pTz
.DaylightBias
!=0)
91 iLeap
= (res
->tm_year
% 4 == 0 && (res
->tm_year
% 100 != 0 || res
->tm_year
% 400 == 0));
92 // based on leap select which group to use
94 res
->tm_mday
= systime
.wDay
;
95 res
->tm_min
= systime
.wMinute
;
96 res
->tm_mon
= systime
.wMonth
;
97 res
->tm_sec
= systime
.wSecond
;
98 res
->tm_wday
= systime
.wDayOfWeek
;
99 res
->tm_yday
= __mon_yday
[iLeap
][systime
.wMonth
] + systime
.wDay
;
100 res
->tm_year
= systime
.wYear
;// this the correct year but bias the value to start at the 1900
101 res
->tm_year
= res
->tm_year
- 1900;
107 time_t __cdecl
time(time_t *)
113 size_t __cdecl
wcsftime(wchar_t *, size_t, const wchar_t *,
120 time_t __cdecl
mktime(struct tm
*)
126 struct tm
* __cdecl
gmtime(const time_t *)