]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/date.h
GUI thread update and event corrections.
[wxWidgets.git] / include / wx / date.h
index 9f964d35fe0185e65d5ef559657e4165d1691a62..1b3f2e778894d4a8adab62d17f5a9baaee501dab 100644 (file)
@@ -123,7 +123,7 @@ public:
     wxDate &Set(long lJulian)
         { m_date.Set((double)(lJulian + 0.5)); return (wxDate&)*this; }
     wxDate &Set(int nMonth, int nDay, int nYear)
-        { m_date.Set(nDay, (wxDateTime::Month)nMonth, nYear); return (wxDate&)*this; }
+        { m_date.Set(nDay, (wxDateTime::Month)nMonth, nYear); return *this; }
 
     // May also pass neg# to decrement
     wxDate &AddWeeks(int nCount = 1)
@@ -179,11 +179,11 @@ public:
 
     wxDate Previous(int dayOfWeek) const
     {
+        wxDate prev = *this;
         int dow = GetDayOfWeek();
-        if ( dayOfWeek <= dow )
-            return *this - (dow - dayOfWeek);
-        else
-            return *this - 7 + (dayOfWeek - dow);
+        prev -= dayOfWeek > dow ? 7 - (dayOfWeek - dow) : dow - dayOfWeek;
+
+        return prev;
     }
 
     wxString FormatDate(int type = -1) const