aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-11-13 15:34:34 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-11-13 15:34:34 -0500
commit7291b8d3e4712c393a8493982895d4a7ce3ca233 (patch)
treefed5f228365a11568f49c8f1be69230012fe7ddd /MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
parenta5162df829e01e5273b22e79b95609622cb912bb (diff)
use DateTime.TryParse
Diffstat (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs')
-rw-r--r--MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs28
1 files changed, 26 insertions, 2 deletions
diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
index 1176407ce..d4fa74a86 100644
--- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
+++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
@@ -178,11 +178,35 @@ namespace MediaBrowser.Common.Implementations.Security
Email = response.email,
PlanType = response.planType,
SupporterKey = response.supporterKey,
- ExpirationDate = string.IsNullOrWhiteSpace(response.expDate) ? (DateTime?)null : DateTime.Parse(response.expDate),
- RegistrationDate = DateTime.Parse(response.regDate),
IsActiveSupporter = IsMBSupporter
};
+ if (!string.IsNullOrWhiteSpace(response.expDate))
+ {
+ DateTime parsedDate;
+ if (DateTime.TryParse(response.expDate, out parsedDate))
+ {
+ info.ExpirationDate = parsedDate;
+ }
+ else
+ {
+ _logger.Error("Failed to parse expDate: {0}", response.expDate);
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(response.regDate))
+ {
+ DateTime parsedDate;
+ if (DateTime.TryParse(response.regDate, out parsedDate))
+ {
+ info.RegistrationDate = parsedDate;
+ }
+ else
+ {
+ _logger.Error("Failed to parse regDate: {0}", response.regDate);
+ }
+ }
+
info.IsExpiredSupporter = info.ExpirationDate.HasValue && info.ExpirationDate < DateTime.UtcNow && !string.IsNullOrWhiteSpace(info.SupporterKey);
return info;