diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a17c9..db98a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Added GetParentUri method to UriExtensions +## [14.2.0] - 2021-02-04 +### Changed + - ProcessorUtils Uptime methods changed to StartTime + ## [14.1.0] - 2021-01-21 ### Added - Added overload to GuidUtils that takes an enumerable of guids and combines them into a new deterministic guid diff --git a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs index f42b52c..3b9bc65 100644 --- a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs +++ b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs @@ -228,21 +228,6 @@ namespace ICD.Common.Utils IcdConsole.SendControlSystemCommand("reboot", ref consoleResult); } - /// - /// Gets the uptime for the system - /// - /// - [PublicAPI] - public static TimeSpan GetSystemUptime() - { - if (s_SystemUptimeStartTimeUtc == null) - UpdateSystemStartTime(); - - if (s_SystemUptimeStartTimeUtc != null) - return IcdEnvironment.GetUtcTime() - s_SystemUptimeStartTimeUtc.Value; - return default(TimeSpan); - } - /// /// Gets the time the system was started /// DateTime that uptime starts @@ -262,26 +247,27 @@ namespace ICD.Common.Utils /// /// [PublicAPI] - public static TimeSpan GetProgramUptime() + public static DateTime? GetProgramStartTime() { - if (s_ProgramUptimeStartTimeUtc == null) - { - string uptime = GetProgramUptimeFeedback((int)ProgramUtils.ProgramNumber); - Match match = Regex.Match(uptime, UPTIME_REGEX); - if (!match.Success) - return default(TimeSpan); + if (s_ProgramUptimeStartTimeUtc != null) + return s_ProgramUptimeStartTimeUtc; - int days = int.Parse(match.Groups["days"].Value); - int hours = int.Parse(match.Groups["hours"].Value); - int minutes = int.Parse(match.Groups["minutes"].Value); - int seconds = int.Parse(match.Groups["seconds"].Value); - int milliseconds = int.Parse(match.Groups["milliseconds"].Value); - TimeSpan span = new TimeSpan(days, hours, minutes, seconds, milliseconds); - s_ProgramUptimeStartTimeUtc = IcdEnvironment.GetUtcTime() - span; - } + string uptime = GetProgramUptimeFeedback((int)ProgramUtils.ProgramNumber); + Match match = Regex.Match(uptime, UPTIME_REGEX); + if (!match.Success) + return null; - return IcdEnvironment.GetUtcTime() - s_ProgramUptimeStartTimeUtc.Value; + int days = int.Parse(match.Groups["days"].Value); + int hours = int.Parse(match.Groups["hours"].Value); + int minutes = int.Parse(match.Groups["minutes"].Value); + int seconds = int.Parse(match.Groups["seconds"].Value); + int milliseconds = int.Parse(match.Groups["milliseconds"].Value); + + TimeSpan span = new TimeSpan(days, hours, minutes, seconds, milliseconds); + s_ProgramUptimeStartTimeUtc = IcdEnvironment.GetUtcTime() - span; + + return s_ProgramUptimeStartTimeUtc; } #endregion diff --git a/ICD.Common.Utils/ProcessorUtils.Standard.cs b/ICD.Common.Utils/ProcessorUtils.Standard.cs index cfa1a58..a043bf6 100644 --- a/ICD.Common.Utils/ProcessorUtils.Standard.cs +++ b/ICD.Common.Utils/ProcessorUtils.Standard.cs @@ -137,16 +137,6 @@ namespace ICD.Common.Utils throw new NotSupportedException(); } - /// - /// Gets the uptime for the system - /// - /// - [PublicAPI] - public static TimeSpan GetSystemUptime() - { - return TimeSpan.FromMilliseconds(Environment.TickCount); - } - /// /// Gets the time the system was started /// DateTime that uptime starts @@ -162,14 +152,14 @@ namespace ICD.Common.Utils } /// - /// Gets the uptime + /// Gets the time the program was started + /// Datetime the program starts /// /// [PublicAPI] - public static TimeSpan GetProgramUptime() + public static DateTime? GetProgramStartTime() { - var current = System.Diagnostics.Process.GetCurrentProcess(); - return IcdEnvironment.GetLocalTime() - current.StartTime; + return GetSystemStartTime(); } #endregion diff --git a/ICD.Common.Utils/Properties/AssemblyInfo.cs b/ICD.Common.Utils/Properties/AssemblyInfo.cs index 8d23892..8652651 100644 --- a/ICD.Common.Utils/Properties/AssemblyInfo.cs +++ b/ICD.Common.Utils/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ using System.Reflection; [assembly: AssemblyCompany("ICD Systems")] [assembly: AssemblyProduct("ICD.Common.Utils")] [assembly: AssemblyCopyright("Copyright © ICD Systems 2021")] -[assembly: AssemblyVersion("14.1.0.0")] +[assembly: AssemblyVersion("14.2.0.0")]