feat: implement caldav search

This commit is contained in:
2022-04-18 12:47:47 +02:00
parent f9e8f4b9c1
commit d7191461eb
57 changed files with 3893 additions and 20 deletions

View File

@ -0,0 +1,8 @@
package values
type ComponentName string
const (
CalendarComponentName ComponentName = "VCALENDAR"
EventComponentName = "VEVENT"
)

View File

@ -0,0 +1,31 @@
package values
import (
"encoding/xml"
"errors"
"github.com/dolanor/caldav-go/icalendar/values"
"time"
)
// a representation of a date and time for iCalendar
type DateTime struct {
name string
t time.Time
}
// creates a new caldav datetime representation, must be in UTC
func NewDateTime(name string, t time.Time) (*DateTime, error) {
if t.Location() != time.UTC {
return nil, errors.New("CalDAV datetime must be in UTC")
} else {
return &DateTime{name: name, t: t.Truncate(time.Second)}, nil
}
}
// encodes the datetime value for the iCalendar specification
func (d *DateTime) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
layout := values.UTCDateTimeFormatString
value := d.t.Format(layout)
attr := xml.Attr{Name: name, Value: value}
return attr, nil
}

View File

@ -0,0 +1,8 @@
package values
type HumanBoolean string
const (
YesHumanBoolean HumanBoolean = "yes"
NoHumanBoolean = "no"
)

View File

@ -0,0 +1,8 @@
package values
type TextCollation string
const (
OctetTextCollation TextCollation = "i;octet"
ASCIICaseMapCollation = "i;ascii-casemap"
)