Skip to content

Commit

Permalink
[StringUtils] correctly format negative values in SecondsToTimeString()
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Jan 16, 2017
1 parent 571d039 commit 70fa8bd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xbmc/utils/StringUtils.cpp
Expand Up @@ -933,6 +933,8 @@ long StringUtils::TimeStringToSeconds(const std::string &timeString)

std::string StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format)
{
bool isNegative = lSeconds < 0;
lSeconds = abs(lSeconds);
int hh = lSeconds / 3600;
lSeconds = lSeconds % 3600;
int mm = lSeconds / 60;
Expand All @@ -949,6 +951,8 @@ std::string StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format)
strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", mm);
if (format & TIME_FORMAT_SS)
strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", ss);
if (isNegative)
strHMS = "-" + strHMS;
return strHMS;
}

Expand Down

0 comments on commit 70fa8bd

Please sign in to comment.