Ignore time component of SYSTEMTIME in wxCalendarCtrl.

Native month calendar functions doesn't always return correct values in the
time part of SYSTEMTIME so ignore it and use just the date component.

To simplify doing it, add helper (MSW-specific) SetFromMSWSysDate() and
GetAsMSWSysDate() functions which convert between wxDateTime and SYSTEMTIME
but take only date component into account.

This commit partially replaces changes of r63560 and closes #11276.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-05-04 21:59:17 +00:00
parent 79309be9db
commit 10acc3ef6a
3 changed files with 40 additions and 14 deletions

View File

@@ -2347,6 +2347,14 @@ wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st)
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
}
wxDateTime& wxDateTime::SetFromMSWSysDate(const SYSTEMTIME& st)
{
return Set(st.wDay,
static_cast<wxDateTime::Month>(wxDateTime::Jan + st.wMonth - 1),
st.wYear,
0, 0, 0, 0);
}
void wxDateTime::GetAsMSWSysTime(SYSTEMTIME* st) const
{
const wxDateTime::Tm tm(GetTm());
@@ -2361,6 +2369,22 @@ void wxDateTime::GetAsMSWSysTime(SYSTEMTIME* st) const
st->wSecond = tm.sec;
st->wMilliseconds = tm.msec;
}
void wxDateTime::GetAsMSWSysDate(SYSTEMTIME* st) const
{
const wxDateTime::Tm tm(GetTm());
st->wYear = (WXWORD)tm.year;
st->wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1);
st->wDay = tm.mday;
st->wDayOfWeek =
st->wHour =
st->wMinute =
st->wSecond =
st->wMilliseconds = 0;
}
#endif // __WXMSW__
#endif // wxUSE_DATETIME