X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cf9f6737895ace461dcc8ce55ba56bebb97c6a4b..f0fbbe236452ae27a7577deafbbc44ace2c209e7:/src/common/datetime.cpp diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index f6ad3f6259..8346806913 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -487,8 +487,10 @@ static wxString CallStrftime(const wxString& format, const tm* tm) if ( !wxStrftime(buf, WXSIZEOF(buf), format, tm) ) { - // buffer is too small? + // if the format is valid, buffer must be too small? wxFAIL_MSG(_T("strftime() failed")); + + buf[0] = '\0'; } s = buf; @@ -3665,6 +3667,11 @@ wxDateTime::ParseFormat(const wxString& date, Tm tm = tmDef; // set the date + if ( haveMon ) + { + tm.mon = mon; + } + if ( haveYear ) { tm.year = year; @@ -3673,16 +3680,15 @@ wxDateTime::ParseFormat(const wxString& date, // TODO we don't check here that the values are consistent, if both year // day and month/day were found, we just ignore the year day and we // also always ignore the week day - if ( haveMon && haveDay ) + if ( haveDay ) { - if ( mday > GetNumOfDaysInMonth(tm.year, mon) ) + if ( mday > GetNumOfDaysInMonth(tm.year, tm.mon) ) { wxLogDebug(_T("bad month day in wxDateTime::ParseFormat")); return NULL; } - tm.mon = mon; tm.mday = mday; } else if ( haveYDay ) @@ -4596,7 +4602,7 @@ WXDLLIMPEXP_BASE void wxPrevWDay(wxDateTime::WeekDay& wd) wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st) { return Set(st.wDay, - wx_static_cast(wxDateTime::Month, wxDateTime::Jan + st.wMonth - 1), + static_cast(wxDateTime::Jan + st.wMonth - 1), st.wYear, 0, 0, 0); }