Fix ambiguous mm/dd that start with weekday

Options were not being properly passed to recursive parseTime call.
This commit is contained in:
Klondike Dragon 2023-12-18 23:40:08 -07:00
parent 4f7e8545ec
commit 4d76f597be
2 changed files with 4 additions and 1 deletions

View File

@ -1259,7 +1259,7 @@ iterRunes:
// using skip throws off indices used by other code; saner to restart // using skip throws off indices used by other code; saner to restart
newDateStr := p.datestr[i+1:] newDateStr := p.datestr[i+1:]
putBackParser(p) putBackParser(p)
return parseTime(newDateStr, loc) return parseTime(newDateStr, loc, opts...)
} }
// X // X

View File

@ -701,6 +701,9 @@ var testInputs = []dateTest{
{in: "19/03/2012 10:11:59", out: "2012-03-19 10:11:59 +0000 UTC", preferDayFirst: true}, {in: "19/03/2012 10:11:59", out: "2012-03-19 10:11:59 +0000 UTC", preferDayFirst: true},
{in: "19/03/2012 10:11:59.3186369", out: "2012-03-19 10:11:59.3186369 +0000 UTC", retryAmbiguous: true}, {in: "19/03/2012 10:11:59.3186369", out: "2012-03-19 10:11:59.3186369 +0000 UTC", retryAmbiguous: true},
{in: "19/03/2012 10:11:59.3186369", out: "2012-03-19 10:11:59.3186369 +0000 UTC", preferDayFirst: true}, {in: "19/03/2012 10:11:59.3186369", out: "2012-03-19 10:11:59.3186369 +0000 UTC", preferDayFirst: true},
// For certain parse modes that restart parsing, make sure that parsing options are passed along!
{in: "Monday 19/03/2012 10:11:59", out: "2012-03-19 10:11:59 +0000 UTC", retryAmbiguous: true},
{in: "Monday 19/03/2012 10:11:59", out: "2012-03-19 10:11:59 +0000 UTC", preferDayFirst: true},
// https://github.com/araddon/dateparse/issues/105 // https://github.com/araddon/dateparse/issues/105
{in: "20/5/2006 19:51:45", out: "2006-05-20 19:51:45 +0000 UTC", retryAmbiguous: true}, {in: "20/5/2006 19:51:45", out: "2006-05-20 19:51:45 +0000 UTC", retryAmbiguous: true},
{in: "20/5/2006 19:51:45", out: "2006-05-20 19:51:45 +0000 UTC", preferDayFirst: true}, {in: "20/5/2006 19:51:45", out: "2006-05-20 19:51:45 +0000 UTC", preferDayFirst: true},