Support 4 day month: "sept. 28, 2017" closes #62

This commit is contained in:
Aaron Raddon 2018-07-10 18:51:27 -07:00
parent 89c8cfc1bf
commit b703960732
2 changed files with 17 additions and 5 deletions

View File

@ -670,7 +670,6 @@ iterRunes:
// Thu, 13 Jul 2017 08:58:40 +0100
// Tue, 11 Jul 2017 16:28:13 +0200 (CEST)
// Mon, 02-Jan-06 15:04:05 MST
switch {
case r == ' ':
if i > 3 {
@ -713,9 +712,19 @@ iterRunes:
// just lay down the skip, no need to fill and then skip
}
case r == '.':
// sept. 28, 2017
// jan. 28, 2017
p.stateDate = dateAlphaPeriodWsDigit
p.molen = i
p.set(0, "Jan")
if i == 3 {
p.molen = i
p.set(0, "Jan")
} else if i == 4 {
// gross
datestr = datestr[0:i-1] + datestr[i+1:]
return parseTime(datestr, loc)
} else {
return nil, unknownErr(datestr)
}
}
case dateAlphaWs:

View File

@ -11,8 +11,8 @@ import (
func TestOne(t *testing.T) {
time.Local = time.UTC
var ts time.Time
ts = MustParse("2018-06-29 19:09:57.77297118 +0300 +03")
assert.Equal(t, "2018-06-29 16:09:57.77297118 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
ts = MustParse("sept. 28, 2017")
assert.Equal(t, "2017-09-28 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
}
type dateTest struct {
@ -27,6 +27,8 @@ var testInputs = []dateTest{
{in: "Oct. 7, '70", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "oct. 7, '70", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "oct. 7, 1970", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "Sept. 7, '70", out: "1970-09-07 00:00:00 +0000 UTC"},
{in: "sept. 7, 1970", out: "1970-09-07 00:00:00 +0000 UTC"},
{in: "Feb 8, 2009 5:57:51 AM", out: "2009-02-08 05:57:51 +0000 UTC"},
{in: "May 8, 2009 5:57:51 PM", out: "2009-05-08 17:57:51 +0000 UTC"},
{in: "May 8, 2009 5:57:1 PM", out: "2009-05-08 17:57:01 +0000 UTC"},
@ -423,6 +425,7 @@ var testParseErrors = []dateTest{
{in: "5,000-9,999", err: true},
{in: "xyzq-baad"},
{in: "oct.-7-1970", err: true},
{in: "septe. 7, 1970", err: true},
}
func TestParseErrors(t *testing.T) {