new format: 2017-12-11 10:16 no seconds closes #31

This commit is contained in:
Aaron Raddon 2017-12-11 10:53:38 -08:00
parent f30ca3179c
commit 39fde9de9e
2 changed files with 10 additions and 1 deletions

View File

@ -668,7 +668,13 @@ iterRunes:
}
case stateDigitDashWs: // starts digit then dash 02- then whitespace 1 << 2 << 5 + 3
// 2013-04-01 22:43:22
// 2013-04-01 22:43
switch len(datestr) {
case len("2013-04-01 22:43"):
return parse("2006-01-02 15:04", datestr, loc)
default:
return parse("2006-01-02 15:04:05", datestr, loc)
}
case stateDigitDashWsWsOffset:
// 2006-01-02 15:04:05 -0700

View File

@ -365,6 +365,9 @@ func TestParse(t *testing.T) {
ts = MustParse("2012-08-03 18:31:59.257000000")
assert.Equal(t, "2012-08-03 18:31:59.257 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
ts = MustParse("2013-04-01 22:43")
assert.Equal(t, "2013-04-01 22:43:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))
ts = MustParse("2013-04-01 22:43:22")
assert.Equal(t, "2013-04-01 22:43:22 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC)))