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:
parent
004e432e7c
commit
214f2f008e
2 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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{}
|
||||
|
|
Loading…
Reference in a new issue