From: Vadim Zeitlin Date: Thu, 18 Sep 2003 22:51:50 +0000 (+0000) Subject: corrected parsing of dates like 01.02.03 (where year can be confused with the day... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/560e2916a9c790150fab69be3e4fb74909a76cbc corrected parsing of dates like 01.02.03 (where year can be confused with the day) in ParseDate() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23695 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index ce2814825e..2ff057c54a 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -3349,18 +3349,27 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date) } else // not the month { - wxDateTime_t maxDays = haveMon - ? GetNumOfDaysInMonth(haveYear ? year : Inv_Year, mon) - : 31; - - // can it be day? - if ( (val == 0) || (val > (unsigned long)maxDays) ) // cast to shut up compiler warning in BCC + if ( haveDay ) { + // this can only be the year isYear = TRUE; } - else + else // may be either day or year { - isDay = TRUE; + wxDateTime_t maxDays = haveMon + ? GetNumOfDaysInMonth(haveYear ? year : Inv_Year, mon) + : 31; + + // can it be day? + if ( (val == 0) || (val > (unsigned long)maxDays) ) + { + // no + isYear = TRUE; + } + else // yes, suppose it's the day + { + isDay = TRUE; + } } }