Skip to content

Commit

Permalink
New date format 1st November 2020
Browse files Browse the repository at this point in the history
  • Loading branch information
iTanken committed Apr 1, 2024
1 parent 71e5bcc commit 82197ca
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 @@ -398,6 +398,12 @@ 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
}
Expand Down
8 changes: 8 additions & 0 deletions parseany_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 82197ca

Please sign in to comment.