mirror of https://github.com/Jackett/Jackett
Make FuzzyTime date format selectable
This commit is contained in:
parent
772df7a4c1
commit
286ef8396a
|
@ -105,10 +105,16 @@ namespace Jackett.Utils
|
|||
|
||||
// Uses the DateTimeRoutines library to parse the date
|
||||
// http://www.codeproject.com/Articles/33298/C-Date-Time-Parser
|
||||
public static DateTime FromFuzzyTime(string str, DateTimeRoutines.DateTimeFormat format = DateTimeRoutines.DateTimeFormat.USA_DATE)
|
||||
public static DateTime FromFuzzyTime(string str, string format = null)
|
||||
{
|
||||
DateTimeRoutines.DateTimeFormat dt_format = DateTimeRoutines.DateTimeFormat.USA_DATE;
|
||||
if (format == "UK")
|
||||
{
|
||||
dt_format = DateTimeRoutines.DateTimeFormat.UK_DATE;
|
||||
}
|
||||
|
||||
DateTimeRoutines.ParsedDateTime dt;
|
||||
if (DateTimeRoutines.TryParseDateOrTime(str, format, out dt))
|
||||
if (DateTimeRoutines.TryParseDateOrTime(str, dt_format, out dt))
|
||||
{
|
||||
return dt.DateTime;
|
||||
}
|
||||
|
@ -122,7 +128,7 @@ namespace Jackett.Utils
|
|||
public static Regex missingYearRegexp = new Regex(@"^\d{1,2}-\d{1,2}\b", RegexOptions.Compiled);
|
||||
public static Regex missingYearRegexp2 = new Regex(@"^(\d{1,2}\s+\w{3})\s+(\d{1,2}\:\d{1,2}.*)$", RegexOptions.Compiled); // 1 Jan 10:30
|
||||
|
||||
public static DateTime FromUnknown(string str)
|
||||
public static DateTime FromUnknown(string str, string format = null)
|
||||
{
|
||||
try {
|
||||
str = ParseUtil.NormalizeSpace(str);
|
||||
|
@ -201,7 +207,8 @@ namespace Jackett.Utils
|
|||
var time = match.Groups[2].Value;
|
||||
str = date + " " + DateTime.Now.Year.ToString() + " " + time;
|
||||
}
|
||||
return FromFuzzyTime(str);
|
||||
|
||||
return FromFuzzyTime(str, format);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue