Correctly format the scanned value of date and time InputFields

This commit is contained in:
jordi fita mas 2023-03-13 14:54:28 +01:00
parent c882158da3
commit c685fc496b
1 changed files with 12 additions and 1 deletions

View File

@ -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
} }