]> repos.lx-s.de Git - winmute.git/commitdiff
Fixed computation of end-time.
authorlx-s <hello@lx-s.de>
Fri, 27 Nov 2020 06:50:43 +0000 (07:50 +0100)
committerlx-s <hello@lx-s.de>
Fri, 27 Nov 2020 06:50:43 +0000 (07:50 +0100)
WinMute/WinMute.cpp

index c6fdf10d06e577622b7b6abddd3fdb1c278c5907..5bf61ff0f3a7a82d13d2488579c10e58e08a1d6d 100644 (file)
@@ -517,13 +517,13 @@ static int GetDiffMillseconds(const LPSYSTEMTIME t1, const LPSYSTEMTIME t2)
    __int64 it1 = ConvertSystemTimeTo100NS(t1);
    __int64 it2 = ConvertSystemTimeTo100NS(t2);
 
-   __int64 res = it1 - it2;
-
-   res /= (1000000000 / 100); // To seconds
-   if (res < 0) { // Add 24 Hours for Wrap Around
-      res += 24 * 60 * 60;
+   // 100NS to Milliseconds;
+   it1 /= 10000;
+   it2 /= 10000;
+   if (it1 < it2) { // add one day wrap around
+      it1 += 24 * 60 * 60 * 1000;
    }
-   res *= 1000; // To Milliseconds
+   __int64 res = it1 - it2;
 
    return static_cast<int>(res);
 }