diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f1d7f..a9780ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + - Added Public API Properties to get the program install date based on the creation date of core dll file for NetStandard and SimplSharp + - Implemented processor utils for NetStandard to get the system uptime and the program uptime ### Changed - Fixed a bug where ANSI color encoded strings with percentages were being scrambled diff --git a/ICD.Common.Utils/ProcessorUtils.Standard.cs b/ICD.Common.Utils/ProcessorUtils.Standard.cs index 5755431..a69cd0d 100644 --- a/ICD.Common.Utils/ProcessorUtils.Standard.cs +++ b/ICD.Common.Utils/ProcessorUtils.Standard.cs @@ -142,8 +142,7 @@ namespace ICD.Common.Utils [PublicAPI] public static TimeSpan GetSystemUptime() { - // TODO - return default(TimeSpan); + return TimeSpan.FromMilliseconds(Environment.TickCount); } /// @@ -153,8 +152,8 @@ namespace ICD.Common.Utils [PublicAPI] public static TimeSpan GetProgramUptime() { - // TODO - return default(TimeSpan); + var current = System.Diagnostics.Process.GetCurrentProcess(); + return IcdEnvironment.GetLocalTime() - current.StartTime; } #endregion diff --git a/ICD.Common.Utils/ProgramUtils.SimplSharp.cs b/ICD.Common.Utils/ProgramUtils.SimplSharp.cs index c1c692f..d4d9e5f 100644 --- a/ICD.Common.Utils/ProgramUtils.SimplSharp.cs +++ b/ICD.Common.Utils/ProgramUtils.SimplSharp.cs @@ -1,4 +1,5 @@ -using ICD.Common.Utils.Services; +using ICD.Common.Utils.IO; +using ICD.Common.Utils.Services; using ICD.Common.Utils.Services.Logging; #if SIMPLSHARP using Crestron.SimplSharp; @@ -86,6 +87,16 @@ namespace ICD.Common.Utils } } + /// + /// Returns the date and time the program was installed. + /// + /// + [PublicAPI] + public static DateTime ProgramInstallDate + { + get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); } + } + /// /// Parses the prog comments and pulls program information. /// diff --git a/ICD.Common.Utils/ProgramUtils.Standard.cs b/ICD.Common.Utils/ProgramUtils.Standard.cs index cfbaafc..916dfc4 100644 --- a/ICD.Common.Utils/ProgramUtils.Standard.cs +++ b/ICD.Common.Utils/ProgramUtils.Standard.cs @@ -55,6 +55,15 @@ namespace ICD.Common.Utils return Assembly.GetEntryAssembly().GetName().Name; } } - } + + /// + /// Gets the date and time the program was installed. + /// + [PublicAPI] + public static DateTime ProgramInstallDate + { + get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); } + } + } } #endif