diff --git a/parseany.go b/parseany.go index b9668b2..a74dfdc 100644 --- a/parseany.go +++ b/parseany.go @@ -400,6 +400,14 @@ iterRunes: p.stateDate = dateDigitChineseYear case ',': return nil, unknownErr(datestr) + + case 's', 'S', 'r', 'R', 't', 'T', 'n', 'N': + // 1st January 2018 + // 2nd Jan 2018 23:59 + // st, rd, nd, st + p.stateDate = dateAlphaWsMonthSuffix + i-- + default: continue } diff --git a/parseany_test.go b/parseany_test.go index 7fea1e6..5bb61ee 100644 --- a/parseany_test.go +++ b/parseany_test.go @@ -417,6 +417,14 @@ var testInputs = []dateTest{ {in: "1384216367111", out: "2013-11-12 00:32:47.111 +0000 UTC"}, {in: "1384216367111222", out: "2013-11-12 00:32:47.111222 +0000 UTC"}, {in: "1384216367111222333", out: "2013-11-12 00:32:47.111222333 +0000 UTC"}, + + // dd[th,nd,st,rd] Month yyyy + {in: "1st September 2012", out: "2012-09-01 00:00:00 +0000 UTC"}, + {in: "2nd September 2012", out: "2012-09-02 00:00:00 +0000 UTC"}, + {in: "3rd September 2012", out: "2012-09-03 00:00:00 +0000 UTC"}, + {in: "4th September 2012", out: "2012-09-04 00:00:00 +0000 UTC"}, + {in: "2nd January 2018", out: "2018-01-02 00:00:00 +0000 UTC"}, + {in: "3nd Feb 2018 13:58:24", out: "2018-02-03 13:58:24 +0000 UTC"}, } func TestParse(t *testing.T) {