dateparse icon indicating copy to clipboard operation
dateparse copied to clipboard

20/5/2006 19:51:45 produces an error month out of range

Open asannikov opened this issue 4 years ago • 1 comments

I added test case: {in: "20/5/2006 19:51:45", out: "2006-05-20 19:51:45 +0000 UTC"}, and it's failed with an error:

❯ go test -cover
--- FAIL: TestParse (0.00s)
panic: parsing time "20/5/2006 19:51:45": month out of range [recovered]
        panic: parsing time "20/5/2006 19:51:45": month out of range

goroutine 20 [running]:
testing.tRunner.func1.1(0x12d1680, 0xc000099000)
        /usr/local/go/src/testing/testing.go:941 +0x3d0
testing.tRunner.func1(0xc0000d0900)
        /usr/local/go/src/testing/testing.go:944 +0x3f9
panic(0x12d1680, 0xc000099000)
        /usr/local/go/src/runtime/panic.go:967 +0x166
..../golang/dateparse.MustParse(0x1343561, 0x12, 0x0, 0x0, 0x12e3d20)
..../golang/dateparse/parseany.go:177 +0xfe
..../golang/dateparse.TestParse(0xc0000d0900)
..../golang/dateparse/parseany_test.go:60 +0xb10
testing.tRunner(0xc0000d0900, 0x1357e08)
        /usr/local/go/src/testing/testing.go:992 +0xdc
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:1043 +0x357
exit status 2
FAIL    ..../golang/dateparse        0.350s

asannikov avatar Jun 17 '20 22:06 asannikov

This is fixed in https://github.com/araddon/dateparse/pull/89 by setting the retryAmbiguousDateWithSwap ParserOption to true

troyspencer avatar Jul 16 '20 16:07 troyspencer