mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
use DateTime.TryParse
This commit is contained in:
parent
a5162df829
commit
7291b8d3e4
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user