calculations

This commit is contained in:
2019-10-22 17:07:33 +02:00
parent 3c74465092
commit 667d06fd9e
12 changed files with 336 additions and 89 deletions
+11 -1
View File
@@ -11,13 +11,23 @@ QString secs2String(const qint32& secs)
{
QTime t;
qint32 h = secs/3600;
bool neg = false;
if(secs < 0)
{
t = QTime(0, 0, 0).addSecs(-secs);
h = -h;
neg = true;
}
else
t = QTime(0, 0, 0).addSecs(secs);
return(QString::number(h) + t.toString(":mm:ss"));
return((neg ? "-" : "") + QString::number(h) + t.toString(":mm:ss"));
}
qint32 time2Secs(const QTime& time)
{
return(time.hour()*3600+time.minute()*60+time.second());
}
#endif //COMMON_H