X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd0b170911637899ac3c126367ee5821f357c185..412e4edfb1174c68fab706abdf735b1ca6fe56f2:/include/wx/date.h diff --git a/include/wx/date.h b/include/wx/date.h index 43209e7f0d..11ff72017f 100644 --- a/include/wx/date.h +++ b/include/wx/date.h @@ -81,8 +81,8 @@ public: long operator-(const wxDate &dt) const { return GetJulianDate() - dt.GetJulianDate(); } - wxDate &operator+=(long i) { m_date += wxTimeSpan::Days(i); return *this; } - wxDate &operator-=(long i) { m_date -= wxTimeSpan::Days(i); return *this; } + wxDate &operator+=(long i) { m_date += wxTimeSpan::Days((int)i); return *this; } + wxDate &operator-=(long i) { m_date -= wxTimeSpan::Days((int)i); return *this; } wxDate &operator++() { return *this += 1; } wxDate &operator++(int) { return *this += 1; } @@ -119,11 +119,11 @@ public: // Sets to current system date wxDate &Set() - { m_date = wxDateTime::Today(); return *this; } + { m_date = wxDateTime::Today(); return (wxDate&)*this; } wxDate &Set(long lJulian) - { m_date.Set((double)(lJulian + 0.5)); return *this; } + { 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); } + { 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