From: lx-s Date: Fri, 27 Nov 2020 06:50:43 +0000 (+0100) Subject: Fixed computation of end-time. X-Git-Tag: 1.6.0~6 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=9e16cdd707493d1cfad9bb34b060aa0ca0dffa08;p=winmute.git Fixed computation of end-time. --- 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); }