More Improvement to unix timestamp performance

pull/1475/head
Qstick 2 years ago
parent 495f61f412
commit 2e9f6cd94b

@ -257,5 +257,18 @@ namespace NzbDrone.Common.Extensions
{
return input.Contains(':') ? $"[{input}]" : input;
}
public static bool IsAllDigits(this string input)
{
foreach (var c in input)
{
if (c < '0' || c > '9')
{
return false;
}
}
return true;
}
}
}

@ -2,6 +2,7 @@ using System;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Parser
{
@ -123,7 +124,7 @@ namespace NzbDrone.Core.Parser
str = str.Trim();
// try parsing the str as an unix timestamp
if (str.All(char.IsDigit) && long.TryParse(str, out var unixTimeStamp))
if (str.IsAllDigits() && long.TryParse(str, out var unixTimeStamp))
{
return UnixTimestampToDateTime(unixTimeStamp);
}

Loading…
Cancel
Save