parse absolute ical timestamps
This commit is contained in:
parent
47486af06d
commit
19ce729df1
|
@ -29,6 +29,7 @@ import (
|
|||
|
||||
// DateFormat ist the caldav date format
|
||||
const DateFormat = `20060102T150405`
|
||||
const DateFormatAbsolute = `20060102T150405Z`
|
||||
|
||||
// Event holds a single caldav event
|
||||
type Event struct {
|
||||
|
|
|
@ -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 = caldav.DateFormatAbsolute
|
||||
}
|
||||
|
||||
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 New Issue