mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Added fix to parse dates of the format 28-Feb-18 and 28-Feb-2018.
This commit is contained in:
parent
d2ba70357e
commit
dd780a39a3
22
parseany.go
22
parseany.go
@ -1551,6 +1551,28 @@ iterRunes:
|
|||||||
// 13-Feb-03 ambiguous
|
// 13-Feb-03 ambiguous
|
||||||
// 28-Feb-03 ambiguous
|
// 28-Feb-03 ambiguous
|
||||||
// 29-Jun-2016
|
// 29-Jun-2016
|
||||||
|
length := len(datestr) - (p.moi + p.molen + 1)
|
||||||
|
if length == 4 {
|
||||||
|
p.yearlen = 4
|
||||||
|
p.set(p.yeari, "2006")
|
||||||
|
// We now also know that part1 was the day
|
||||||
|
p.dayi = 0
|
||||||
|
p.daylen = p.part1Len
|
||||||
|
p.setDay()
|
||||||
|
} else if length == 2 {
|
||||||
|
// We have no idea if this is
|
||||||
|
// yy-mon-dd OR dd-mon-yy
|
||||||
|
//
|
||||||
|
// We are going to ASSUME (bad, bad) that it is dd-mon-yy which is a horible assumption
|
||||||
|
p.ambiguousMD = true
|
||||||
|
p.yearlen = 2
|
||||||
|
p.set(p.yeari, "06")
|
||||||
|
// We now also know that part1 was the day
|
||||||
|
p.dayi = 0
|
||||||
|
p.daylen = p.part1Len
|
||||||
|
p.setDay()
|
||||||
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
|
|
||||||
case dateDigitDot:
|
case dateDigitDot:
|
||||||
|
@ -213,6 +213,9 @@ var testInputs = []dateTest{
|
|||||||
{in: "2014-04-02", out: "2014-04-02 00:00:00 +0000 UTC"},
|
{in: "2014-04-02", out: "2014-04-02 00:00:00 +0000 UTC"},
|
||||||
{in: "2014-03-31", out: "2014-03-31 00:00:00 +0000 UTC"},
|
{in: "2014-03-31", out: "2014-03-31 00:00:00 +0000 UTC"},
|
||||||
{in: "2014-4-2", out: "2014-04-02 00:00:00 +0000 UTC"},
|
{in: "2014-4-2", out: "2014-04-02 00:00:00 +0000 UTC"},
|
||||||
|
// dd-mmm-yy
|
||||||
|
{in: "28-Feb-02", out: "2002-02-28 00:00:00 +0000 UTC"},
|
||||||
|
{in: "15-Jan-18", out: "2018-01-15 00:00:00 +0000 UTC"},
|
||||||
// yyyy-mm
|
// yyyy-mm
|
||||||
{in: "2014-04", out: "2014-04-01 00:00:00 +0000 UTC"},
|
{in: "2014-04", out: "2014-04-01 00:00:00 +0000 UTC"},
|
||||||
// yyyy-mm-dd hh:mm:ss AM
|
// yyyy-mm-dd hh:mm:ss AM
|
||||||
|
Loading…
Reference in New Issue
Block a user