Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

StringUtils::TimeStringToSeconds - clear input string and additional …

…check
  • Loading branch information...
commit a8c96364eafb529afe327ce7a7183955a99c4ebc 1 parent bc09ae1
@Karlson2k Karlson2k authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 xbmc/utils/StringUtils.cpp
View
11 xbmc/utils/StringUtils.cpp
@@ -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]);
Please sign in to comment.
Something went wrong with that request. Please try again.