Skip to content

Commit

Permalink
Support nillable time (pointer) as well
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Sep 13, 2024
1 parent db68110 commit a4c8d35
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/gui/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func decodeRichTextStyle(m map[string]interface{}) (s widget.RichTextStyle) {
switch k {
case "TextStyle":
s.TextStyle = decodeTextStyle(v.(map[string]interface{}))
// TODO more!
// TODO more!
}
}

Expand Down Expand Up @@ -452,6 +452,15 @@ func decodeFields(e reflect.Value, in map[string]interface{}) error {
} else {
f.Set(reflect.ValueOf(t))
}
case "*time.Time":
s := reflect.ValueOf(v).String()

t, err := time.Parse(time.RFC3339, s)
if err != nil {
fyne.LogError("Failed parse time "+s, err)
} else {
f.Set(reflect.ValueOf(&t))
}
default:
if strings.Index(typeName, "int") == 0 {
f.SetInt(int64(reflect.ValueOf(v).Float()))
Expand Down

0 comments on commit a4c8d35

Please sign in to comment.