The old workaround for the 1-Jan-1970 bug still failed in some
timezones. This new workaround seems to work better. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1168,16 +1168,11 @@ wxDateTime& wxDateTime::Set(const struct tm& tm)
|
||||
// less than timezone - try to make it work for this case
|
||||
if ( tm2.tm_year == 70 && tm2.tm_mon == 0 && tm2.tm_mday == 1 )
|
||||
{
|
||||
// add timezone to make sure that date is in range
|
||||
tm2.tm_sec -= GetTimeZone();
|
||||
|
||||
timet = mktime(&tm2);
|
||||
if ( timet != (time_t)-1 )
|
||||
{
|
||||
timet += GetTimeZone();
|
||||
|
||||
return Set(timet);
|
||||
}
|
||||
return Set((time_t)(
|
||||
GetTimeZone() +
|
||||
tm2.tm_hour * MIN_PER_HOUR * SEC_PER_MIN +
|
||||
tm2.tm_min * SEC_PER_MIN +
|
||||
tm2.tm_sec));
|
||||
}
|
||||
|
||||
wxFAIL_MSG( _T("mktime() failed") );
|
||||
@@ -1262,7 +1257,10 @@ wxDateTime& wxDateTime::Set(wxDateTime_t day,
|
||||
(void)Set(tm);
|
||||
|
||||
// and finally adjust milliseconds
|
||||
return SetMillisecond(millisec);
|
||||
if (IsValid())
|
||||
SetMillisecond(millisec);
|
||||
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user