mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Make FuzzyTime date format selectable
This commit is contained in:
@@ -105,10 +105,16 @@ namespace Jackett.Utils
|
|||||||
|
|
||||||
// Uses the DateTimeRoutines library to parse the date
|
// Uses the DateTimeRoutines library to parse the date
|
||||||
// http://www.codeproject.com/Articles/33298/C-Date-Time-Parser
|
// 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;
|
DateTimeRoutines.ParsedDateTime dt;
|
||||||
if (DateTimeRoutines.TryParseDateOrTime(str, format, out dt))
|
if (DateTimeRoutines.TryParseDateOrTime(str, dt_format, out dt))
|
||||||
{
|
{
|
||||||
return dt.DateTime;
|
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 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 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 {
|
try {
|
||||||
str = ParseUtil.NormalizeSpace(str);
|
str = ParseUtil.NormalizeSpace(str);
|
||||||
@@ -201,7 +207,8 @@ namespace Jackett.Utils
|
|||||||
var time = match.Groups[2].Value;
|
var time = match.Groups[2].Value;
|
||||||
str = date + " " + DateTime.Now.Year.ToString() + " " + time;
|
str = date + " " + DateTime.Now.Year.ToString() + " " + time;
|
||||||
}
|
}
|
||||||
return FromFuzzyTime(str);
|
|
||||||
|
return FromFuzzyTime(str, format);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user