diff --git a/parseany.go b/parseany.go index c8a4040..bd8171d 100644 --- a/parseany.go +++ b/parseany.go @@ -212,10 +212,19 @@ func ParseAny(datestr string) (time.Time, error) { } else { u.Error("unknown format: ", datestr) } - case !f.Has(HAS_SLASH): + default: // 3/1/2014 // 10/13/2014 // 01/02/2006 + if t, err := time.Parse("01/02/2006", datestr); err == nil { + return t, nil + } else { + if t, err := time.Parse("1/2/2006", datestr); err == nil { + return t, nil + } else { + u.Error(err) + } + } } case f.Has(HAS_ALPHA) && f.Has(HAS_COMMA): switch { diff --git a/parseany_test.go b/parseany_test.go index 84afc1d..b333960 100644 --- a/parseany_test.go +++ b/parseany_test.go @@ -75,10 +75,15 @@ func TestParse(t *testing.T) { //u.Debug(ts.Unix(), ts) assert.T(t, ts.Unix() == 1396994700) + ts, err = ParseAny("3/31/2014") + assert.T(t, err == nil) + //u.Debug(ts.Unix(), ts) + assert.T(t, ts.Unix() == 1396224000) + // Unix Time Stamp ts, err = ParseAny("1332151919") assert.T(t, err == nil) - u.Debug(ts.Unix(), ts) + //u.Debug(ts.Unix(), ts) assert.T(t, ts.Unix() == 1332151919) ts2, err := ParseAny("2009-08-12T22:15:09-07:00")