forked from mirror/gin
Fix time.Time binding (#904)
If a empty string is given(`""`), them time should be zero.
This commit is contained in:
parent
957f6205c8
commit
6a3a8ae61b
|
@ -152,6 +152,11 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
|
||||||
if timeFormat == "" {
|
if timeFormat == "" {
|
||||||
return errors.New("Blank time format")
|
return errors.New("Blank time format")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if val == "" {
|
||||||
|
value.Set(reflect.ValueOf(time.Time{}))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
l := time.Local
|
l := time.Local
|
||||||
if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {
|
if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {
|
||||||
|
|
Loading…
Reference in New Issue