Explorar o código

Fix time.Time binding (#904)

If a empty string is given(`""`), them time should be zero.
Andrey Nering %!s(int64=8) %!d(string=hai) anos
pai
achega
6a3a8ae61b
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      binding/form_mapping.go

+ 5 - 0
binding/form_mapping.go

@@ -152,6 +152,11 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
 	if timeFormat == "" {
 		return errors.New("Blank time format")
 	}
+	
+	if val == "" {
+		value.Set(reflect.ValueOf(time.Time{}))
+		return nil
+	}
 
 	l := time.Local
 	if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {