1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2025-02-28 08:55:39 +00:00

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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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