setTimeField() — gin Function Reference
Architecture documentation for the setTimeField() function in form_mapping.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 034b9427_1fc8_bb5c_9530_6a9ec5654a35["setTimeField()"] 0bcba57f_f00e_ed0e_0516_ee30758711c8["form_mapping.go"] 034b9427_1fc8_bb5c_9530_6a9ec5654a35 -->|defined in| 0bcba57f_f00e_ed0e_0516_ee30758711c8 258ae74c_d8fe_39e5_de46_9ff457fed54a["setWithProperType()"] 258ae74c_d8fe_39e5_de46_9ff457fed54a -->|calls| 034b9427_1fc8_bb5c_9530_6a9ec5654a35 style 034b9427_1fc8_bb5c_9530_6a9ec5654a35 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
Defined In
Called By
Source
Frequently Asked Questions
What does setTimeField() do?
setTimeField() is a function in the gin codebase, defined in binding/form_mapping.go.
Where is setTimeField() defined?
setTimeField() is defined in binding/form_mapping.go at line 434.
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