mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 03:41:55 +08:00
commit
6b43995a97
@ -240,7 +240,7 @@ func parseTime(datestr string, loc *time.Location, opts ...ParserOption) (p *par
|
|||||||
// this is because it means that a day is being interpreted as a month and overflowing the valid value for that
|
// this is because it means that a day is being interpreted as a month and overflowing the valid value for that
|
||||||
// by retrying in this case, we can fix a common situation with no assumptions
|
// by retrying in this case, we can fix a common situation with no assumptions
|
||||||
defer func() {
|
defer func() {
|
||||||
if p.ambiguousMD {
|
if p != nil && p.ambiguousMD {
|
||||||
// if it errors out with the following error, swap before we
|
// if it errors out with the following error, swap before we
|
||||||
// get out of this function to reduce scope it needs to be applied on
|
// get out of this function to reduce scope it needs to be applied on
|
||||||
_, err := p.parse()
|
_, err := p.parse()
|
||||||
|
@ -520,6 +520,9 @@ func TestParseErrors(t *testing.T) {
|
|||||||
for _, th := range testParseErrors {
|
for _, th := range testParseErrors {
|
||||||
v, err := ParseAny(th.in)
|
v, err := ParseAny(th.in)
|
||||||
assert.NotEqual(t, nil, err, "%v for %v", v, th.in)
|
assert.NotEqual(t, nil, err, "%v for %v", v, th.in)
|
||||||
|
|
||||||
|
v, err = ParseAny(th.in, RetryAmbiguousDateWithSwap(true))
|
||||||
|
assert.NotEqual(t, nil, err, "%v for %v", v, th.in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user