Correctly format the scanned value of date and time InputFields
This commit is contained in:
parent
c882158da3
commit
c685fc496b
13
pkg/form.go
13
pkg/form.go
|
@ -35,7 +35,18 @@ func (field *InputField) Scan(value interface{}) error {
|
||||||
field.Val = ""
|
field.Val = ""
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
field.Val = fmt.Sprintf("%v", value)
|
switch v := value.(type) {
|
||||||
|
case time.Time:
|
||||||
|
if field.Type == "date" {
|
||||||
|
field.Val = v.Format("2006-01-02")
|
||||||
|
} else if field.Type == "time" {
|
||||||
|
field.Val = v.Format("15:04")
|
||||||
|
} else {
|
||||||
|
field.Val = v.Format(time.RFC3339)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
field.Val = fmt.Sprintf("%v", v)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue