fix: Program and Processor utils actually return DateTimes for date properties

This commit is contained in:
Drew Tingen
2020-04-27 11:09:58 -04:00
committed by Chris Cameron
parent 69eb4b3d34
commit 49d12d454f
4 changed files with 31 additions and 10 deletions

View File

@@ -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.
/// </summary>
[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<ILoggerService>()
.AddEntry(eSeverity.Warning, "Unable to get model version date from \"{0}\"", VersionResult);
return string.Empty;
return DateTime.MinValue;
}
}

View File

@@ -31,12 +31,12 @@ namespace ICD.Common.Utils
/// Gets the date that the firmware was updated.
/// </summary>
[PublicAPI]
public static string ModelVersionDate
public static DateTime ModelVersionDate
{
get
{
// TODO
return null;
return DateTime.MinValue;
}
}

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;
@@ -40,7 +41,16 @@ namespace ICD.Common.Utils
/// Gets the compile date of the program.
/// </summary>
[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;
}
}
/// <summary>
/// Gets the compiler revision version.
@@ -86,6 +96,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)).ToUniversalTime(); }
}
/// <summary>
/// Parses the prog comments and pulls program information.
/// </summary>

View File

@@ -18,11 +18,11 @@ namespace ICD.Common.Utils
/// Gets the compile date of the program.
/// </summary>
[PublicAPI]
public static string CompiledDate
public static DateTime CompiledDate
{
get
{
return IcdFile.GetLastWriteTime(Assembly.GetEntryAssembly().Location).ToString();
return IcdFile.GetLastWriteTime(Assembly.GetEntryAssembly().Location);
}
}