diff --git a/binding/form_mapping.go b/binding/form_mapping.go index db2045f400..f7e41e2483 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -397,12 +397,13 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val timeFormat = time.RFC3339 } + if val == "" { + value.Set(reflect.ValueOf(time.Time{})) + return nil + } + switch tf := strings.ToLower(timeFormat); tf { case "unix", "unixnano": - if val == "" { - val = "0" - } - tv, err := strconv.ParseInt(val, 10, 64) if err != nil { return err @@ -418,11 +419,6 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val return nil } - if val == "" { - value.Set(reflect.ValueOf(time.Time{})) - return nil - } - l := time.Local if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC { l = time.UTC