Add "yyyy-MM-dd HH:mm:ss" string format

This commit is contained in:
emacsist 2016-11-16 09:33:54 +08:00 committed by Bjørn Erik Pedersen
parent 2580bc98dc
commit 24b6558033
2 changed files with 8 additions and 0 deletions

View File

@ -212,3 +212,10 @@ func TestToDuration(t *testing.T) {
assert.Equal(t, v.expected, ToDuration(v.input))
}
}
func TestStringToDate(t *testing.T) {
d := "2016-03-06 15:28:01"
format := "2006-01-02 15:04:05"
v, _ := time.Parse(format, d)
assert.Equal(t, ToTime(d), v)
}

View File

@ -513,6 +513,7 @@ func StringToDate(s string) (time.Time, error) {
"02 Jan 2006",
"2006-01-02 15:04:05 -07:00",
"2006-01-02 15:04:05 -0700",
"2006-01-02 15:04:05",
})
}