Merge branch 'feat/uptime-utils' of Common/Utils into ConnectPro_v1.4

This commit is contained in:
Chris Cameron
2019-09-03 14:02:26 +00:00
committed by Gogs
4 changed files with 28 additions and 6 deletions

View File

@@ -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

View File

@@ -142,8 +142,7 @@ namespace ICD.Common.Utils
[PublicAPI]
public static TimeSpan GetSystemUptime()
{
// TODO
return default(TimeSpan);
return TimeSpan.FromMilliseconds(Environment.TickCount);
}
/// <summary>
@@ -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

View File

@@ -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
}
}
/// <summary>
/// Returns the date and time the program was installed.
/// </summary>
/// <returns></returns>
[PublicAPI]
public static DateTime ProgramInstallDate
{
get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); }
}
/// <summary>
/// Parses the prog comments and pulls program information.
/// </summary>

View File

@@ -55,6 +55,15 @@ namespace ICD.Common.Utils
return Assembly.GetEntryAssembly().GetName().Name;
}
}
}
/// <summary>
/// Gets the date and time the program was installed.
/// </summary>
[PublicAPI]
public static DateTime ProgramInstallDate
{
get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); }
}
}
}
#endif