DateTimeUtils: Add support for parsing unix timestamps (#628)

This commit is contained in:
kaso17
2016-11-02 19:04:56 +01:00
committed by GitHub
parent 6f38081cf1
commit c3a5c7afa3

View File

@@ -156,6 +156,19 @@ namespace Jackett.Utils
return dt;
}
try
{
// try parsing the str as an unix timestamp
var unixTimeStamp = long.Parse(str);
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
dt = dt.AddSeconds(unixTimeStamp).ToLocalTime();
return dt;
}
catch (FormatException)
{
// it wasn't a timestamp, continue....
}
// add missing year
match = missingYearRegexp.Match(str);
if (match.Success)