mirror of
https://gitee.com/johng/gf
synced 2026-07-08 14:39:50 +08:00
improve gtime.ParseTimeFromContent
This commit is contained in:
@ -259,6 +259,7 @@ func formatToRegexPattern(format string) string {
|
||||
s := gregex.Quote(formatToStdLayout(format))
|
||||
s, _ = gregex.ReplaceString(`[0-9]`, `[0-9]`, s)
|
||||
s, _ = gregex.ReplaceString(`[A-Za-z]`, `[A-Za-z]`, s)
|
||||
s, _ = gregex.ReplaceString(`\s+`, `\s+`, s)
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
@ -275,6 +275,11 @@ func Test_ParseTimeFromContent(t *testing.T) {
|
||||
t.Error("test fail")
|
||||
}
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := "2021-1-27 9:10:24"
|
||||
t.Assert(gtime.ParseTimeFromContent(timeStr, "Y-n-d g:i:s").String(), "2021-01-27 09:10:24")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_FuncCost(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user