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:
Robin Dunn
2004-10-27 01:06:45 +00:00
parent 410bb8c16b
commit 3d78a53231

View File

@@ -1168,16 +1168,11 @@ wxDateTime& wxDateTime::Set(const struct tm& tm)
// less than timezone - try to make it work for this case // less than timezone - try to make it work for this case
if ( tm2.tm_year == 70 && tm2.tm_mon == 0 && tm2.tm_mday == 1 ) if ( tm2.tm_year == 70 && tm2.tm_mon == 0 && tm2.tm_mday == 1 )
{ {
// add timezone to make sure that date is in range return Set((time_t)(
tm2.tm_sec -= GetTimeZone(); GetTimeZone() +
tm2.tm_hour * MIN_PER_HOUR * SEC_PER_MIN +
timet = mktime(&tm2); tm2.tm_min * SEC_PER_MIN +
if ( timet != (time_t)-1 ) tm2.tm_sec));
{
timet += GetTimeZone();
return Set(timet);
}
} }
wxFAIL_MSG( _T("mktime() failed") ); wxFAIL_MSG( _T("mktime() failed") );
@@ -1262,7 +1257,10 @@ wxDateTime& wxDateTime::Set(wxDateTime_t day,
(void)Set(tm); (void)Set(tm);
// and finally adjust milliseconds // and finally adjust milliseconds
return SetMillisecond(millisec); if (IsValid())
SetMillisecond(millisec);
return *this;
} }
else else
{ {