mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-04-19 03:10:50 +02:00
More Improvement to unix timestamp performance
This commit is contained in:
parent
495f61f412
commit
2e9f6cd94b
2 changed files with 15 additions and 1 deletions
|
|
@ -257,5 +257,18 @@ public static string ToUrlHost(this string input)
|
|||
{
|
||||
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.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Parser
|
||||
{
|
||||
|
|
@ -123,7 +124,7 @@ public static DateTime FromUnknown(string str, string format = null)
|
|||
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…
Reference in a new issue