]> git.saurik.com Git - wxWidgets.git/commitdiff
The old workaround for the 1-Jan-1970 bug still failed in some
authorRobin Dunn <robin@alldunn.com>
Wed, 27 Oct 2004 01:06:45 +0000 (01:06 +0000)
committerRobin Dunn <robin@alldunn.com>
Wed, 27 Oct 2004 01:06:45 +0000 (01:06 +0000)
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

src/common/datetime.cpp

index 270d1106342639ed4c1fc14a423fc0be097282dc..9f275a81585a4bb53be1ce1ac0e506c358c4d336 100644 (file)
@@ -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
     {