blob: 7e15d19b35d1f0870aad0582397bd46e48ee28b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
diff --git a/mythtv/libs/libmythbase/mythdate.cpp b/mythtv/libs/libmythbase/mythdate.cpp
index 8f3397241a6..21a307cb453 100644
--- a/mythtv/libs/libmythbase/mythdate.cpp
+++ b/mythtv/libs/libmythbase/mythdate.cpp
@@ -237,6 +237,9 @@ QString formatTime(std::chrono::milliseconds msecs, QString fmt)
static const QRegularExpression sRe("s+");
static const QRegularExpression zRe("z+");
+ bool negativeTime = msecs < 0ms;
+ msecs = std::chrono::milliseconds(std::abs(msecs.count()));
+
QRegularExpressionMatch match = hRe.match(fmt);
if (match.hasMatch())
{
@@ -272,6 +275,10 @@ QString formatTime(std::chrono::milliseconds msecs, QString fmt)
QString text = StringUtil::intToPaddedString(value, width);
fmt.replace(match.capturedStart(), match.capturedLength(), text);
}
+
+ if (negativeTime)
+ fmt.prepend("-");
+
return fmt;
}
|