Merge pull request #4775 from jmarshallnz/empty_episode_playcount
[vuplus_xbmc] / xbmc / XBDateTime.cpp
index 93b29c2..995f9b7 100644 (file)
@@ -696,6 +696,9 @@ bool CDateTime::SetFromDateString(const CStdString &date)
     return false;
   }
 
+  if (SetFromDBDate(date))
+    return true;
+
   const char* months[] = {"january","february","march","april","may","june","july","august","september","october","november","december",NULL};
   int j=0;
   size_t iDayPos = date.find("day");
@@ -709,8 +712,8 @@ bool CDateTime::SetFromDateString(const CStdString &date)
     iDayPos = 0;
 
   CStdString strMonth = date.substr(iDayPos, iPos - iDayPos);
-  if (strMonth.empty()) // assume dbdate format
-    return SetFromDBDate(date);
+  if (strMonth.empty())
+    return false;
 
   size_t iPos2 = date.find(",");
   CStdString strDay = (date.size() >= iPos) ? date.substr(iPos, iPos2-iPos) : "";
@@ -984,14 +987,15 @@ bool CDateTime::SetFromDBDate(const CStdString &date)
     return false;
   // assumes format:
   // YYYY-MM-DD or DD-MM-YYYY
+  const static std::string sep_chars = "-./";
   int year = 0, month = 0, day = 0;
-  if (date[2] == '-' || date[2] == '.')
+  if (sep_chars.find(date[2]) != std::string::npos)
   {
     day = atoi(date.substr(0, 2).c_str());
     month = atoi(date.substr(3, 2).c_str());
     year = atoi(date.substr(6, 4).c_str());
   }
-  else
+  else if (sep_chars.find(date[4]) != std::string::npos)
   {
     year = atoi(date.substr(0, 4).c_str());
     month = atoi(date.substr(5, 2).c_str());