mirror of
https://github.com/araddon/dateparse.git
synced 2025-01-19 11:16:12 +08:00
Add support for dd-month-year format
This commit is contained in:
parent
7a3c923820
commit
65e6e8d1a9
13
parseany.go
13
parseany.go
@ -635,9 +635,22 @@ iterRunes:
|
||||
switch r {
|
||||
case '-', '\u2212':
|
||||
p.molen = i - p.moi
|
||||
|
||||
// Must be a valid short or long month
|
||||
if p.molen == 3 {
|
||||
p.set(p.moi, "Jan")
|
||||
p.yeari = i + 1
|
||||
p.stateDate = dateDigitDashAlphaDash
|
||||
} else {
|
||||
possibleFullMonth := strings.ToLower(p.datestr[p.moi:(p.moi + p.molen)])
|
||||
if i > 3 && isMonthFull(possibleFullMonth) {
|
||||
p.fullMonth = possibleFullMonth
|
||||
p.yeari = i + 1
|
||||
p.stateDate = dateDigitDashAlphaDash
|
||||
} else {
|
||||
return p, p.unknownErr(datestr)
|
||||
}
|
||||
}
|
||||
default:
|
||||
if !unicode.IsLetter(r) {
|
||||
return p, p.unknownErr(datestr)
|
||||
|
@ -403,7 +403,7 @@ var testInputs = []dateTest{
|
||||
{in: "15-Jan-2017", out: "2017-01-15 00:00:00 +0000 UTC"},
|
||||
{in: "28-Feb-02 15:16:17", out: "2002-02-28 15:16:17 +0000 UTC"},
|
||||
{in: "15-Jan-18 15:16:17", out: "2018-01-15 15:16:17 +0000 UTC"},
|
||||
{in: "15-Jan-2017 15:16:17", out: "2017-01-15 15:16:17 +0000 UTC"},
|
||||
{in: "15-September-2017 15:16:17", out: "2017-09-15 15:16:17 +0000 UTC"},
|
||||
// dd-mm-yy (digit month - potentially ambiguous) - https://github.com/araddon/dateparse/issues/139
|
||||
{in: "28-02-02", out: "2002-02-28 00:00:00 +0000 UTC"},
|
||||
{in: "15-01-18", out: "2018-01-15 00:00:00 +0000 UTC"},
|
||||
|
Loading…
Reference in New Issue
Block a user