Skip to content

Commit

Permalink
Add support for dd[th,nd,st,rd] Month yyyy
Browse files Browse the repository at this point in the history
  • Loading branch information
klondikedragon committed Dec 13, 2023
1 parent c62ed15 commit 49f9259
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions parseany.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,12 @@ iterRunes:
p.stateDate = dateDigitChineseYear
case ',':
return p, 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
}
Expand Down
8 changes: 8 additions & 0 deletions parseany_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ var testInputs = []dateTest{
{in: "June 2nd 2012", out: "2012-06-02 00:00:00 +0000 UTC"},
{in: "June 22nd, 2012", out: "2012-06-22 00:00:00 +0000 UTC"},
{in: "June 22nd 2012", out: "2012-06-22 00:00:00 +0000 UTC"},
// Incorporate PR https://github.com/araddon/dateparse/pull/128 to fix https://github.com/araddon/dateparse/issues/127
// 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"},
// RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
{in: "Fri, 03 Jul 2015 08:08:08 MST", out: "2015-07-03 08:08:08 +0000 UTC", zname: "MST"},
{in: "Fri, 03 Jul 2015 08:08:08 CET", out: "2015-07-03 08:08:08 +0000 UTC", zname: "CET"},
Expand Down

0 comments on commit 49f9259

Please sign in to comment.