From 9e16cdd707493d1cfad9bb34b060aa0ca0dffa08 Mon Sep 17 00:00:00 2001 From: lx-s Date: Fri, 27 Nov 2020 07:50:43 +0100 Subject: [PATCH] Fixed computation of end-time. --- WinMute/WinMute.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index c6fdf10..5bf61ff 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -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(res); } -- 2.43.0