From 7c4e33fd65ca329bd8fd2605d7c79c084ec25123 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Wed, 22 Mar 2023 11:39:46 -0400
Subject: mythtv: add negative_time_values.patch

---
 linhes/mythtv/PKGBUILD                   |  4 +++-
 linhes/mythtv/negative_time_values.patch | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 linhes/mythtv/negative_time_values.patch

diff --git a/linhes/mythtv/PKGBUILD b/linhes/mythtv/PKGBUILD
index f3504ac..d23e545 100644
--- a/linhes/mythtv/PKGBUILD
+++ b/linhes/mythtv/PKGBUILD
@@ -8,7 +8,7 @@
 
 pkgname=mythtv
 pkgver=33+fixes.20230313.7f288be6
-pkgrel=2
+pkgrel=3
 pkgdesc="A Homebrew PVR project"
 arch=('x86_64')
 url="https://www.mythtv.org/"
@@ -86,6 +86,7 @@ patches="0031-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.
          0227-OSD-Add-interlaced-status-to-OSD-debug-screen.patch
          autoskip_reduce_commskip_jumpback.patch
          defaultThemeLinHES.patch
+         negative_time_values.patch
          mythfrontend_en_us.ts_Title_Case.patch"
 
 source=(
@@ -110,6 +111,7 @@ sha256sums=('SKIP'
             '630c80c588a9b278c4421d356c5cbaa0debf149524bc896656b580b89d8fae88'
             '8a81e724d902976056dc824e7304df343c230ce67ec6ce1d18e110c5ef818ef6'
             'ef1d0053d862a9c714093d375e20c96418d665fa504a5b8f30621a271d416dd8'
+            'c1e1b2bca9c3f4d5f862d44ae45bba484b5b4afd3030a2ddbb0c8c5efc4c68da'
             '6c6047d676635375f44fd219b989ed99602ed3260a8a5757195831dcc8a7c1bc')
 
 prepare() {
diff --git a/linhes/mythtv/negative_time_values.patch b/linhes/mythtv/negative_time_values.patch
new file mode 100644
index 0000000..7e15d19
--- /dev/null
+++ b/linhes/mythtv/negative_time_values.patch
@@ -0,0 +1,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;
+ }
+ 
-- 
cgit v0.12

