From 811891134ee9d4da5a217a670ac5a2dcd0202059 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 20 May 2020 19:32:53 +0200 Subject: plugins/caldav: add time inputs in event create/update form --- plugins/caldav/plugin.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'plugins/caldav/plugin.go') diff --git a/plugins/caldav/plugin.go b/plugins/caldav/plugin.go index caeb12a..e8d14a9 100644 --- a/plugins/caldav/plugin.go +++ b/plugins/caldav/plugin.go @@ -10,6 +10,11 @@ import ( "git.sr.ht/~emersion/alps" ) +const ( + inputDateLayout = "2006-01-02" + inputTimeLayout = "15:04" +) + func sanityCheckURL(u *url.URL) error { req, err := http.NewRequest(http.MethodOptions, u.String(), nil) if err != nil { @@ -61,13 +66,16 @@ func newPlugin(srv *alps.Server) (alps.Plugin, error) { p.TemplateFuncs(template.FuncMap{ "formatinputdate": func(t time.Time) string { - return t.Format("2006-01-02") + if t.IsZero() { + return "" + } + return t.Format(inputDateLayout) }, - "ornow": func(t time.Time) time.Time { + "formatinputtime": func(t time.Time) string { if t.IsZero() { - return time.Now() + return "" } - return t + return t.Format(inputTimeLayout) }, }) -- cgit v1.2.3-59-g8ed1b