Support absolute iCal timestamps in CalDAV requests (#691)

no need to export from there I think

parse absolute ical timestamps

Co-authored-by: konrad <konrad@kola-entertainments.de>
Co-authored-by: Martin Giger <martin@humanoids.be>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/691
Co-Authored-By: freaktechnik <martin@humanoids.be>
Co-Committed-By: freaktechnik <martin@humanoids.be>
This commit is contained in:
freaktechnik 2020-10-19 09:11:15 +00:00 committed by konrad
parent 004e432e7c
commit 214f2f008e
2 changed files with 10 additions and 2 deletions

View file

@ -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

View file

@ -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{}