setTimeField() — gin Function Reference
Architecture documentation for the setTimeField() function in form_mapping.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 6c0372d3_bbee_c861_3919_16056a8d9721["setTimeField()"] 6153aa3f_ed0b_2237_43a1_5d4f68982dd7["setWithProperType()"] 6153aa3f_ed0b_2237_43a1_5d4f68982dd7 -->|calls| 6c0372d3_bbee_c861_3919_16056a8d9721 style 6c0372d3_bbee_c861_3919_16056a8d9721 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
binding/form_mapping.go lines 434–488
func setTimeField(val string, structField reflect.StructField, value reflect.Value) error {
timeFormat := structField.Tag.Get("time_format")
if timeFormat == "" {
timeFormat = time.RFC3339
}
if val == "" {
value.Set(reflect.ValueOf(time.Time{}))
return nil
}
switch tf := strings.ToLower(timeFormat); tf {
case "unix", "unixmilli", "unixmicro", "unixnano":
tv, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return err
}
var t time.Time
switch tf {
case "unix":
t = time.Unix(tv, 0)
case "unixmilli":
t = time.UnixMilli(tv)
case "unixmicro":
t = time.UnixMicro(tv)
default:
t = time.Unix(0, tv)
}
value.Set(reflect.ValueOf(t))
return nil
}
l := time.Local
if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {
l = time.UTC
}
if locTag := structField.Tag.Get("time_location"); locTag != "" {
loc, err := time.LoadLocation(locTag)
if err != nil {
return err
}
l = loc
}
t, err := time.ParseInLocation(timeFormat, val, l)
if err != nil {
return err
}
value.Set(reflect.ValueOf(t))
return nil
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does setTimeField() do?
setTimeField() is a function in the gin codebase.
What calls setTimeField()?
setTimeField() is called by 1 function(s): setWithProperType.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free