really fixed bug with DST in Set(h, m, s, ms) (see patch 1097811)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32350 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-02-24 16:51:43 +00:00
parent 7474e2cb62
commit 456639ac87

View File

@@ -1291,18 +1291,21 @@ wxDateTime& wxDateTime::Set(wxDateTime_t hour,
wxDATETIME_CHECK( tm, _T("localtime() failed") ); wxDATETIME_CHECK( tm, _T("localtime() failed") );
// make a copy so it isn't clobbered by the call to mktime() below
struct tm tm1(*tm);
// adjust the time // adjust the time
tm->tm_hour = hour; tm1.tm_hour = hour;
tm->tm_min = minute; tm1.tm_min = minute;
tm->tm_sec = second; tm1.tm_sec = second;
// and the DST in case it changes on this date // and the DST in case it changes on this date
struct tm tm2(*tm); struct tm tm2(tm1);
mktime(&tm2); mktime(&tm2);
if ( tm2.tm_isdst != tm->tm_isdst ) if ( tm2.tm_isdst != tm1.tm_isdst )
tm->tm_isdst = tm2.tm_isdst; tm1.tm_isdst = tm2.tm_isdst;
(void)Set(*tm); (void)Set(tm1);
// and finally adjust milliseconds // and finally adjust milliseconds
return SetMillisecond(millisec); return SetMillisecond(millisec);