diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-11-13 15:48:21 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-11-13 15:48:21 -0500 |
| commit | 578fc7be143528dc53f79fd941551b00e3214b00 (patch) | |
| tree | 9dfe9f0582dfc48a84714cfcb4cc36a3b84a1aae /MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | |
| parent | c7af567e5c3abcd59ba5a287d2509eb282810759 (diff) | |
use DateTime.TryParse
Diffstat (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | 28 |
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; |
