mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
fix: Fixed 4-series version string date parsing error
This commit is contained in:
@@ -110,13 +110,33 @@ namespace ICD.Common.Utils
|
|||||||
Regex regex = new Regex(VER_REGEX);
|
Regex regex = new Regex(VER_REGEX);
|
||||||
Match match = regex.Match(VersionResult);
|
Match match = regex.Match(VersionResult);
|
||||||
|
|
||||||
if (match.Success)
|
if (!match.Success)
|
||||||
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 DateTime.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
ServiceProvider.TryGetService<ILoggerService>()
|
string date = match.Groups["date"].Value;
|
||||||
.AddEntry(eSeverity.Warning, "Unable to get model version date from \"{0}\"", VersionResult);
|
|
||||||
|
try
|
||||||
return DateTime.MinValue;
|
{
|
||||||
|
switch (IcdEnvironment.RuntimeEnvironment)
|
||||||
|
{
|
||||||
|
case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
|
||||||
|
date = StringUtils.RemoveDuplicateWhitespace(date);
|
||||||
|
return DateTime.ParseExact(date, "MMM d yyyy", CultureInfo.InvariantCulture).ToUniversalTime();
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DateTime.ParseExact(date, "MMM dd yyyy", CultureInfo.InvariantCulture).ToUniversalTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
ServiceProvider.TryGetService<ILoggerService>()
|
||||||
|
.AddEntry(eSeverity.Warning, "Failed to parse date \"{0}\"", date);
|
||||||
|
return DateTime.MinValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user