Convert to lower case before compare

This commit is contained in:
Magne Sjaastad 2017-10-05 07:55:03 +02:00
parent fd785044eb
commit 4016681286
2 changed files with 6 additions and 3 deletions

View File

@ -135,7 +135,7 @@ bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month)
sMonth = trimString(sMonth); sMonth = trimString(sMonth);
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
if (MONTH_NAMES[i].compare(0, s.size(), s) == 0) if (MONTH_NAMES[i].compare(0, sMonth.size(), sMonth) == 0)
{ {
month = i + 1; month = i + 1;
return true; return true;
@ -192,10 +192,13 @@ bool RiaDateStringParser::containsAlphabetic(const std::string& s)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::string RiaDateStringParser::trimString(std::string& s) std::string RiaDateStringParser::trimString(const std::string& s)
{ {
auto sCopy = s.substr(0, s.find_last_not_of(' ') + 1); auto sCopy = s.substr(0, s.find_last_not_of(' ') + 1);
sCopy = sCopy.substr(sCopy.find_first_not_of(' ')); sCopy = sCopy.substr(sCopy.find_first_not_of(' '));
std::transform(sCopy.begin(), sCopy.end(), sCopy.begin(), ::tolower);
return sCopy; return sCopy;
} }

View File

@ -40,6 +40,6 @@ private:
static bool tryParseDay(const std::string& s, int &day); static bool tryParseDay(const std::string& s, int &day);
static bool containsAlphabetic(const std::string& s); static bool containsAlphabetic(const std::string& s);
static std::string trimString(std::string& s); static std::string trimString(const std::string& s);
}; };