From 7631b1c38722e85bc1ae8b1d9db4ebcc23eeec1e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 2 Mar 2022 13:48:14 -0500 Subject: [PATCH] Core/Common: Add a TimeSpan interface to TimeTrackerSmall Port From (https://github.com/TrinityCore/TrinityCore/commit/35e0002df3073cf4c3e1dae9fbff73d75ddb5e98) --- Source/Framework/Util/Time.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/Framework/Util/Time.cs b/Source/Framework/Util/Time.cs index 772e7d48e..2af585e1a 100644 --- a/Source/Framework/Util/Time.cs +++ b/Source/Framework/Util/Time.cs @@ -346,11 +346,21 @@ public class TimeTrackerSmall i_expiryTime = expiry; } + public TimeTrackerSmall(TimeSpan expiry = default) + { + i_expiryTime = (int)expiry.TotalMilliseconds; + } + public void Update(int diff) { i_expiryTime -= diff; } + public void Update(TimeSpan diff) + { + Update((int)diff.TotalMilliseconds); + } + public bool Passed() { return i_expiryTime <= 0; @@ -361,10 +371,16 @@ public class TimeTrackerSmall i_expiryTime = interval; } - public int GetExpiry() + public void Reset(TimeSpan expiry) { - return i_expiryTime; + Reset((int)expiry.TotalMilliseconds); } + + public TimeSpan GetExpiry() + { + return TimeSpan.FromMilliseconds(i_expiryTime); + } + int i_expiryTime; }