X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64f9c1009476cd0a347d6c3dfc93993652cbd199..dc683654a1af7f02ee87623a713a7147bcb6dd84:/src/common/datetime.cpp diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index ec0c9c5ccf..caf8b036ce 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -1291,18 +1291,21 @@ wxDateTime& wxDateTime::Set(wxDateTime_t hour, 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 - tm->tm_hour = hour; - tm->tm_min = minute; - tm->tm_sec = second; + tm1.tm_hour = hour; + tm1.tm_min = minute; + tm1.tm_sec = second; // and the DST in case it changes on this date - struct tm tm2(*tm); + struct tm tm2(tm1); mktime(&tm2); - if ( tm2.tm_isdst != tm->tm_isdst ) - tm->tm_isdst = tm2.tm_isdst; + if ( tm2.tm_isdst != tm1.tm_isdst ) + tm1.tm_isdst = tm2.tm_isdst; - (void)Set(*tm); + (void)Set(tm1); // and finally adjust milliseconds return SetMillisecond(millisec);