Skip to content

Commit 21df004

Browse files
committed
Additional missed format for refs #74 date format with rd
1 parent 313f117 commit 21df004

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

parseany.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -786,15 +786,12 @@ iterRunes:
786786
return parseTime(fmt.Sprintf("%s%s", p.datestr[0:i], p.datestr[i+2:]), loc)
787787
}
788788
}
789-
// case ',':
790-
// // x
791-
// // April 8th, 2009
792-
// case ' ':
793-
// // x
794-
// // April 8th 2009
795-
// // p.yeari = i + 1
796-
// p.yeari = i + 1
797-
// p.stateDate = dateAlphaWsMonthMore
789+
case 'r', 'R':
790+
if p.nextIs(i, 'd') || p.nextIs(i, 'D') {
791+
if len(datestr) > i+2 {
792+
return parseTime(fmt.Sprintf("%s%s", p.datestr[0:i], p.datestr[i+2:]), loc)
793+
}
794+
}
798795
}
799796
case dateAlphaWsMore:
800797
// January 02, 2006, 15:04:05

parseany_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var testInputs = []dateTest{
8888
{in: "May 7, 2012", out: "2012-05-07 00:00:00 +0000 UTC"},
8989
{in: "June 7, 2012", out: "2012-06-07 00:00:00 +0000 UTC"},
9090
{in: "June 7 2012", out: "2012-06-07 00:00:00 +0000 UTC"},
91-
// Month dd[th,nd,st] yyyy
91+
// Month dd[th,nd,st,rd] yyyy
9292
{in: "September 17th, 2012", out: "2012-09-17 00:00:00 +0000 UTC"},
9393
{in: "September 17th 2012", out: "2012-09-17 00:00:00 +0000 UTC"},
9494
{in: "September 7th, 2012", out: "2012-09-07 00:00:00 +0000 UTC"},
@@ -97,6 +97,8 @@ var testInputs = []dateTest{
9797
{in: "May 1st, 2012", out: "2012-05-01 00:00:00 +0000 UTC"},
9898
{in: "May 21st 2012", out: "2012-05-21 00:00:00 +0000 UTC"},
9999
{in: "May 21st, 2012", out: "2012-05-21 00:00:00 +0000 UTC"},
100+
{in: "May 23rd 2012", out: "2012-05-23 00:00:00 +0000 UTC"},
101+
{in: "May 23rd, 2012", out: "2012-05-23 00:00:00 +0000 UTC"},
100102
{in: "June 2nd, 2012", out: "2012-06-02 00:00:00 +0000 UTC"},
101103
{in: "June 2nd 2012", out: "2012-06-02 00:00:00 +0000 UTC"},
102104
{in: "June 22nd, 2012", out: "2012-06-22 00:00:00 +0000 UTC"},

0 commit comments

Comments
 (0)