|
|
@ -1,5 +1,6 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Parser
|
|
|
|
namespace NzbDrone.Core.Parser
|
|
|
@ -120,6 +121,13 @@ namespace NzbDrone.Core.Parser
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
str = str.Trim();
|
|
|
|
str = str.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try parsing the str as an unix timestamp
|
|
|
|
|
|
|
|
if (str.All(char.IsDigit) && long.TryParse(str, out var unixTimeStamp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return UnixTimestampToDateTime(unixTimeStamp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (str.ToLower().Contains("now"))
|
|
|
|
if (str.ToLower().Contains("now"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return DateTime.UtcNow;
|
|
|
|
return DateTime.UtcNow;
|
|
|
@ -212,14 +220,6 @@ namespace NzbDrone.Core.Parser
|
|
|
|
return dt;
|
|
|
|
return dt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// try parsing the str as an unix timestamp
|
|
|
|
|
|
|
|
if (long.TryParse(str, out var unixTimeStamp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return UnixTimestampToDateTime(unixTimeStamp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// it wasn't a timestamp, continue....
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// add missing year
|
|
|
|
// add missing year
|
|
|
|
match = _MissingYearRegexp.Match(str);
|
|
|
|
match = _MissingYearRegexp.Match(str);
|
|
|
|
if (match.Success)
|
|
|
|
if (match.Success)
|
|
|
@ -312,7 +312,7 @@ namespace NzbDrone.Core.Parser
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (FormatException ex)
|
|
|
|
catch (FormatException ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new InvalidDateException($"Error while parsing DateTime \"{date}\", using layout \"{layout}\" ({pattern}): {ex.Message}");
|
|
|
|
throw new InvalidDateException($"Error while parsing DateTime \"{date}\", using layout \"{layout}\" ({pattern}): {ex.Message}", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|