mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-12-26 00:16:02 +01:00
More Improvement to unix timestamp performance
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user