From 456639ac872830894e596e99942e282c1ea4293c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 24 Feb 2005 16:51:43 +0000 Subject: [PATCH] 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 --- src/common/datetime.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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); -- 2.47.2