From a1ca7d4421b9aa2786d4df20b9e71dcc632e9d64 Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Wed, 27 Nov 2024 11:31:34 +0530 Subject: [PATCH] [MM-340]: Improved the handling of all day event while rendering events --- calendar/engine/views/calendar.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/calendar/engine/views/calendar.go b/calendar/engine/views/calendar.go index 23d0e535..dcdbda1d 100644 --- a/calendar/engine/views/calendar.go +++ b/calendar/engine/views/calendar.go @@ -151,6 +151,22 @@ func MarkdownToHTMLEntities(input string) string { } func renderEvent(event *remote.Event, asRow bool, timeZone string) (string, error) { + link, err := url.QueryUnescape(event.Weblink) + if err != nil { + return "", err + } + + subject := EnsureSubject(event.Subject) + + if event.IsAllDay { + format := "(All day event) [%s](%s)" + if asRow { + format = "| All day event | [%s](%s) |" + } + + return fmt.Sprintf(format, MarkdownToHTMLEntities(subject), link), nil + } + start := event.Start.In(timeZone).Time().Format(time.Kitchen) end := event.End.In(timeZone).Time().Format(time.Kitchen) @@ -159,13 +175,6 @@ func renderEvent(event *remote.Event, asRow bool, timeZone string) (string, erro format = "| %s - %s | [%s](%s) |" } - link, err := url.QueryUnescape(event.Weblink) - if err != nil { - return "", err - } - - subject := EnsureSubject(event.Subject) - return fmt.Sprintf(format, start, end, MarkdownToHTMLEntities(subject), link), nil }