From 49d12d454f38bd639a941a6852983046622365ae Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Mon, 27 Apr 2020 11:09:58 -0400 Subject: [PATCH 1/2] fix: Program and Processor utils actually return DateTimes for date properties --- ICD.Common.Utils/ProcessorUtils.SimplSharp.cs | 9 +++---- ICD.Common.Utils/ProcessorUtils.Standard.cs | 4 ++-- ICD.Common.Utils/ProgramUtils.SimplSharp.cs | 24 +++++++++++++++++-- ICD.Common.Utils/ProgramUtils.Standard.cs | 4 ++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs index ba6d97d..032ec33 100644 --- a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs +++ b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs @@ -1,4 +1,5 @@ -using ICD.Common.Utils.Services; +using System.Globalization; +using ICD.Common.Utils.Services; using ICD.Common.Utils.Services.Logging; #if SIMPLSHARP using System; @@ -91,7 +92,7 @@ namespace ICD.Common.Utils /// Gets the date that the firmware was updated. /// [PublicAPI] - public static string ModelVersionDate + public static DateTime ModelVersionDate { get { @@ -99,12 +100,12 @@ namespace ICD.Common.Utils Match match = regex.Match(VersionResult); if (match.Success) - return match.Groups["date"].Value; + return DateTime.ParseExact(match.Groups["date"].Value, "MMM dd yyyy", CultureInfo.InvariantCulture).ToUniversalTime(); ServiceProvider.TryGetService() .AddEntry(eSeverity.Warning, "Unable to get model version date from \"{0}\"", VersionResult); - return string.Empty; + return DateTime.MinValue; } } diff --git a/ICD.Common.Utils/ProcessorUtils.Standard.cs b/ICD.Common.Utils/ProcessorUtils.Standard.cs index 5755431..11ee5e1 100644 --- a/ICD.Common.Utils/ProcessorUtils.Standard.cs +++ b/ICD.Common.Utils/ProcessorUtils.Standard.cs @@ -31,12 +31,12 @@ namespace ICD.Common.Utils /// Gets the date that the firmware was updated. /// [PublicAPI] - public static string ModelVersionDate + public static DateTime ModelVersionDate { get { // TODO - return null; + return DateTime.MinValue; } } diff --git a/ICD.Common.Utils/ProgramUtils.SimplSharp.cs b/ICD.Common.Utils/ProgramUtils.SimplSharp.cs index c1c692f..dfc3aa5 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; @@ -40,7 +41,16 @@ namespace ICD.Common.Utils /// Gets the compile date of the program. /// [PublicAPI] - public static string CompiledDate { get { return ProgComments.GetDefault(COMPILED_ON_KEY, null); } } + public static DateTime CompiledDate + { + get + { + string dateString; + return ProgComments.TryGetValue(COMPILED_ON_KEY, out dateString) + ? DateTime.Parse(dateString).ToUniversalTime() + : DateTime.MinValue; + } + } /// /// Gets the compiler revision version. @@ -86,6 +96,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)).ToUniversalTime(); } + } + /// /// 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..26cd015 100644 --- a/ICD.Common.Utils/ProgramUtils.Standard.cs +++ b/ICD.Common.Utils/ProgramUtils.Standard.cs @@ -18,11 +18,11 @@ namespace ICD.Common.Utils /// Gets the compile date of the program. /// [PublicAPI] - public static string CompiledDate + public static DateTime CompiledDate { get { - return IcdFile.GetLastWriteTime(Assembly.GetEntryAssembly().Location).ToString(); + return IcdFile.GetLastWriteTime(Assembly.GetEntryAssembly().Location); } } From d90c60126ec1a41694adb7fb66d66cfb7dea2809 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 30 Apr 2020 13:02:14 -0400 Subject: [PATCH 2/2] chore: Updating changelog, incrementing minor version --- CHANGELOG.md | 4 ++++ ICD.Common.Utils/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f0d74f..2ea21a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [8.9.0] - 2020-04-30 +### Changed + - ProgramUtils and ProcessorUtils return dates instead of strings for date properties + ## [8.8.1] - 2020-02-18 ### Changed - IcdTimer - fixed issue that prevented OnElapsed event from firing when Length is less than (or close to) Heartbeat Interval diff --git a/ICD.Common.Utils/Properties/AssemblyInfo.cs b/ICD.Common.Utils/Properties/AssemblyInfo.cs index cdc25ff..1a01e43 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 2020")] -[assembly: AssemblyVersion("8.8.1.0")] +[assembly: AssemblyVersion("8.9.0.0")]