From 79067a961d7c6c6cd0b66e5f0d3119179497aecf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 19 Feb 2002 15:03:00 +0000 Subject: [PATCH 1/1] fixed bug in ParseDateFormat() with numbers with leading zeroes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetime.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 418a72f51c..73973840e1 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -440,7 +440,11 @@ static bool GetNumericToken(size_t len, const wxChar*& p, unsigned long *number) break; } - return !!s && s.ToULong(number); + // use the base 10 explicitly because otherwise the string "09" (the + // leading zeroes are common in the date specifications) is not parsed + // correctly as, according to the standard C rules, it is understood as an + // octal number and '9' is not a valid octal digit! + return !s.empty() && s.ToULong(number, 10); } // scans all alphabetic characters and returns the resulting string @@ -3102,7 +3106,7 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date) // is it a number? unsigned long val; - if ( token.ToULong(&val) ) + if ( token.ToULong(&val, 10) ) // 10: see comment in GetNumericToken() { // guess what this number is -- 2.45.2