diff --git a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs
index 92e07bb..dae07ac 100644
--- a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs
+++ b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs
@@ -238,23 +238,25 @@ namespace ICD.Common.Utils
public static TimeSpan GetSystemUptime()
{
if (s_SystemUptimeStartTimeUtc == null)
- {
- string uptime = GetSystemUptimeFeedback();
- Match match = Regex.Match(uptime, UPTIME_REGEX);
- if (!match.Success)
- return default(TimeSpan);
+ UpdateSystemStartTime();
- 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);
+ if (s_SystemUptimeStartTimeUtc != null)
+ return IcdEnvironment.GetUtcTime() - s_SystemUptimeStartTimeUtc.Value;
+ return default(TimeSpan);
+ }
- TimeSpan span = new TimeSpan(days, hours, minutes, seconds, milliseconds);
- s_SystemUptimeStartTimeUtc = IcdEnvironment.GetUtcTime() - span;
- }
+ ///
+ /// Gets the time the system was started
+ /// DateTime that uptime starts
+ ///
+ ///
+ [PublicAPI]
+ public static DateTime? GetSystemStartTime()
+ {
+ if (s_SystemUptimeStartTimeUtc == null)
+ UpdateSystemStartTime();
- return IcdEnvironment.GetUtcTime() - s_SystemUptimeStartTimeUtc.Value;
+ return s_SystemUptimeStartTimeUtc;
}
///
@@ -286,6 +288,23 @@ namespace ICD.Common.Utils
#endregion
+ private static void UpdateSystemStartTime()
+ {
+ string uptime = GetSystemUptimeFeedback();
+ Match match = Regex.Match(uptime, UPTIME_REGEX);
+ if (!match.Success)
+ return;
+
+ 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_SystemUptimeStartTimeUtc = IcdEnvironment.GetUtcTime() - span;
+ }
+
///
/// Gets the result from the ramfree console command.
///
diff --git a/ICD.Common.Utils/ProcessorUtils.Standard.cs b/ICD.Common.Utils/ProcessorUtils.Standard.cs
index c764ed9..cfa1a58 100644
--- a/ICD.Common.Utils/ProcessorUtils.Standard.cs
+++ b/ICD.Common.Utils/ProcessorUtils.Standard.cs
@@ -6,6 +6,8 @@ namespace ICD.Common.Utils
{
public static partial class ProcessorUtils
{
+ private static DateTime? s_SystemStartTime;
+
#region Properties
///
@@ -145,6 +147,20 @@ namespace ICD.Common.Utils
return TimeSpan.FromMilliseconds(Environment.TickCount);
}
+ ///
+ /// Gets the time the system was started
+ /// DateTime that uptime starts
+ ///
+ ///
+ [PublicAPI]
+ public static DateTime? GetSystemStartTime()
+ {
+ if (s_SystemStartTime == null)
+ s_SystemStartTime = IcdEnvironment.GetUtcTime() - TimeSpan.FromMilliseconds(Environment.TickCount);
+
+ return s_SystemStartTime;
+ }
+
///
/// Gets the uptime
///