From 214f2f008e797f4794d46fb4690c6458b9d6e5f9 Mon Sep 17 00:00:00 2001 From: freaktechnik Date: Mon, 19 Oct 2020 09:11:15 +0000 Subject: [PATCH] Support absolute iCal timestamps in CalDAV requests (#691) no need to export from there I think parse absolute ical timestamps Co-authored-by: konrad Co-authored-by: Martin Giger Reviewed-on: https://kolaente.dev/vikunja/api/pulls/691 Co-Authored-By: freaktechnik Co-Committed-By: freaktechnik --- pkg/caldav/caldav.go | 2 +- pkg/routes/caldav/parsing.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/caldav/caldav.go b/pkg/caldav/caldav.go index f58bb9c570..067a50baef 100644 --- a/pkg/caldav/caldav.go +++ b/pkg/caldav/caldav.go @@ -27,7 +27,7 @@ import ( "code.vikunja.io/api/pkg/utils" ) -// DateFormat ist the caldav date format +// DateFormat is the caldav date format const DateFormat = `20060102T150405` // Event holds a single caldav event diff --git a/pkg/routes/caldav/parsing.go b/pkg/routes/caldav/parsing.go index 455e38d716..547f717e67 100644 --- a/pkg/routes/caldav/parsing.go +++ b/pkg/routes/caldav/parsing.go @@ -18,6 +18,7 @@ package caldav import ( "strconv" + "strings" "time" "code.vikunja.io/api/pkg/caldav" @@ -111,12 +112,19 @@ func parseTaskFromVTODO(content string) (vTask *models.Task, err error) { return } +// https://tools.ietf.org/html/rfc5545#section-3.3.5 func caldavTimeToTimestamp(tstring string) time.Time { if tstring == "" { return time.Time{} } - t, err := time.Parse(caldav.DateFormat, tstring) + format := caldav.DateFormat + + if strings.HasSuffix(tstring, "Z") { + format = `20060102T150405Z` + } + + t, err := time.Parse(format, tstring) if err != nil { log.Warningf("Error while parsing caldav time %s to TimeStamp: %s", tstring, err) return time.Time{}