Skip to content

Commit

Permalink
StringUtils::TimeStringToSeconds - clear input string and additional …
Browse files Browse the repository at this point in the history
…check
  • Loading branch information
Karlson2k committed Oct 2, 2012
1 parent bc09ae1 commit a8c9636
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xbmc/utils/StringUtils.cpp
Expand Up @@ -403,17 +403,20 @@ int StringUtils::DateStringToYYYYMMDD(const CStdString &dateString)

long StringUtils::TimeStringToSeconds(const CStdString &timeString)
{
if(timeString.Right(4).Equals(" min"))
CStdString strCopy(timeString);
strCopy.TrimLeft(" \n\r\t");
strCopy.TrimRight(" \n\r\t");
if(strCopy.Right(4).Equals(" min"))
{
// this is imdb format of "XXX min"
return 60 * atoi(timeString.c_str());
return 60 * atoi(strCopy.c_str());
}
else
{
CStdStringArray secs;
StringUtils::SplitString(timeString, ":", secs);
StringUtils::SplitString(strCopy, ":", secs);
int timeInSecs = 0;
for (unsigned int i = 0; i < secs.size(); i++)
for (unsigned int i = 0; i < 3 && i < secs.size(); i++)
{
timeInSecs *= 60;
timeInSecs += atoi(secs[i]);
Expand Down

0 comments on commit a8c9636

Please sign in to comment.