From ca804ab425a314ced556d0f33ddd54eb6405e6d7 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 4 Nov 2024 16:08:54 +0100 Subject: [PATCH] Default date to now --- backend/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/utils.go b/backend/utils.go index 16588c7..631fe25 100644 --- a/backend/utils.go +++ b/backend/utils.go @@ -40,6 +40,7 @@ func BuildWhereQuery(params interface{}) string { } var associationRe = regexp.MustCompile(`r:(\w+)(?:\(([^)]+)\))?`) + func ParseNote(data string) (NoteData, error) { log.Printf("Parsing note: %q", data) res := NoteData{} @@ -67,6 +68,9 @@ func ParseNote(data string) (NoteData, error) { } } res.Note = strings.Join(note, "\n") + if res.Date.IsZero() { + res.Date = time.Now() + } matches := associationRe.FindAllStringSubmatch(res.Note, -1) for _, match := range matches { @@ -119,4 +123,4 @@ func PersistNoteData(note NoteData) (Note, []Association, error) { } return res, ass, nil -} \ No newline at end of file +}