bug in June 2, 2018 format, short full month. closes #60

This commit is contained in:
Aaron Raddon 2018-06-05 18:01:57 -07:00
parent 5025a49c02
commit 4c29e1d266
2 changed files with 7 additions and 8 deletions

View File

@ -660,9 +660,10 @@ 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 > 4 {
if i > 3 {
prefix := strings.ToLower(datestr[0:i])
for _, month := range months {
if prefix == month {

View File

@ -11,10 +11,9 @@ import (
func TestOne(t *testing.T) {
time.Local = time.UTC
var ts time.Time
// {in: "2015-02-08 03:02:00 +0300 MSK m=+0.000000001", out: "2015-02-08 00:02:00 +0000 UTC"},
// {in: "2015-02-08 03:02:00.001 +0300 MSK m=+0.000000001", out: "2015-02-08 00:02:00.001 +0000 UTC"},
ts = MustParse("April 3, 2018")
assert.Equal(t, "2018-04-03 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
//
ts = MustParse("June 7, 2012")
assert.Equal(t, "2012-06-07 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
}
type dateTest struct {
@ -22,8 +21,6 @@ type dateTest struct {
err bool
}
// {in: , out: },
var testInputs = []dateTest{
{in: "oct 7, 1970", out: "1970-10-07 00:00:00 +0000 UTC"},
{in: "oct 7, '70", out: "1970-10-07 00:00:00 +0000 UTC"},
@ -61,9 +58,10 @@ var testInputs = []dateTest{
// Month dd, yyyy time
{in: "September 17, 2012 at 5:00pm UTC-05", out: "2012-09-17 17:00:00 +0000 UTC"},
{in: "September 17, 2012 at 10:09am PST-08", out: "2012-09-17 18:09:00 +0000 UTC"},
// Monty dd, yyyy
// Month dd, yyyy
{in: "September 17, 2012", out: "2012-09-17 00:00:00 +0000 UTC"},
{in: "May 7, 2012", out: "2012-05-07 00:00:00 +0000 UTC"},
{in: "June 7, 2012", out: "2012-06-07 00:00:00 +0000 UTC"},
// ?
{in: "Fri, 03 Jul 2015 08:08:08 MST", out: "2015-07-03 08:08:08 +0000 UTC"},
{in: "Fri, 03 Jul 2015 08:08:08 PST", out: "2015-07-03 15:08:08 +0000 UTC", loc: "America/Los_Angeles"},