From 4d76f597be8f9b93aeddc67acb051c3585a701bc Mon Sep 17 00:00:00 2001 From: Klondike Dragon Date: Mon, 18 Dec 2023 23:40:08 -0700 Subject: [PATCH] Fix ambiguous mm/dd that start with weekday Options were not being properly passed to recursive parseTime call. --- parseany.go | 2 +- parseany_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/parseany.go b/parseany.go index 46bad4a..76f14a9 100644 --- a/parseany.go +++ b/parseany.go @@ -1259,7 +1259,7 @@ iterRunes: // using skip throws off indices used by other code; saner to restart newDateStr := p.datestr[i+1:] putBackParser(p) - return parseTime(newDateStr, loc) + return parseTime(newDateStr, loc, opts...) } // X diff --git a/parseany_test.go b/parseany_test.go index 000faf2..6eff9cf 100644 --- a/parseany_test.go +++ b/parseany_test.go @@ -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.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}, + // 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 {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},