Skip to content

Commit

Permalink
Improve InstallDate format handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Klocman committed May 20, 2023
1 parent 24a5d6c commit d1f168a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions source/UninstallTools/Factory/RegistryFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,23 @@ private static DateTime GetInstallDate(RegistryKey uninstallerKey)
{
try
{
// Likely to be in YYYYMMDD format
return new DateTime(int.Parse(dateString.Substring(0, 4)),
int.Parse(dateString.Substring(4, 2)),
int.Parse(dateString.Substring(6, 2)));
int.Parse(dateString.Substring(4, 2)),
int.Parse(dateString.Substring(6, 2)));
}
catch (ArgumentOutOfRangeException)
{
try
{
// YYYYDDMM format instead of standard YYYYMMDD?
return new DateTime(int.Parse(dateString.Substring(0, 4)),
int.Parse(dateString.Substring(6, 2)),
int.Parse(dateString.Substring(4, 2)));
}
catch (SystemException)
{
}
}
catch (FormatException)
{
Expand Down

0 comments on commit d1f168a

Please sign in to comment.