core: Convert Parse/Catch to TryParse (#11641)

This commit is contained in:
Alessio Gogna
2021-05-02 04:43:24 +02:00
committed by GitHub
parent db6a8d89a8
commit 47a4f0f422

View File

@@ -176,16 +176,12 @@ namespace Jackett.Common.Utils
return dt; return dt;
} }
try
{
// try parsing the str as an unix timestamp // try parsing the str as an unix timestamp
var unixTimeStamp = long.Parse(str); if (long.TryParse(str, out var unixTimeStamp))
{
return UnixTimestampToDateTime(unixTimeStamp); return UnixTimestampToDateTime(unixTimeStamp);
} }
catch (FormatException)
{
// it wasn't a timestamp, continue.... // it wasn't a timestamp, continue....
}
// add missing year // add missing year
match = _MissingYearRegexp.Match(str); match = _MissingYearRegexp.Match(str);