Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GTime support multiple formats #2933

Merged
merged 7 commits into from
Sep 13, 2023
Merged
9 changes: 7 additions & 2 deletions util/gconv/gconv_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ func GTime(any interface{}, format ...string) *gtime.Time {
}
// Priority conversion using given format.
if len(format) > 0 {
t, _ := gtime.StrToTimeFormat(s, format[0])
return t
for _, item := range format {
t, err := gtime.StrToTimeFormat(s, item)
if t != nil && err == nil {
return t
}
}
return nil
bigger-boss marked this conversation as resolved.
Show resolved Hide resolved
}
if utils.IsNumeric(s) {
return gtime.NewFromTimeStamp(Int64(s))
Expand Down
Loading