Documentation ¶
Index ¶
- Constants
- Variables
- func FromText(s string) string
- func ToText(s string) string
- type Attendee
- type Calendar
- func (cal *Calendar) AddComponent(coms ...Component)
- func (cal *Calendar) GetEvents() []Component
- func (cal *Calendar) SetDescription(st string, pis ...ParamItem)
- func (cal *Calendar) SetLastModified(st string, pis ...ParamItem)
- func (cal *Calendar) SetMethod(st string, pis ...ParamItem)
- func (cal *Calendar) SetProductId(st string, pis ...ParamItem)
- func (cal *Calendar) SetProperty(pname string, val string, pis ...ParamItem)
- func (cal *Calendar) SetVersion(st string, pis ...ParamItem)
- type Component
- type ComponentObj
- type ContentLine
- type Decoder
- type Encoder
- type ParamItem
- type ParamItemObj
- type Parameters
- func (p Parameters) Add(k, v string)
- func (p Parameters) AddItem(pi ParamItem)
- func (p Parameters) Del(k string)
- func (p Parameters) DelItem(pi ParamItem)
- func (p Parameters) Get(name string) string
- func (p Parameters) GetItem(name string) ParamItem
- func (p Parameters) Set(k, v string)
- func (p Parameters) SetItem(pi ParamItem)
- type Property
- func (p *Property) GetParamValue() string
- func (p *Property) GetToBinary() ([]byte, error)
- func (p *Property) GetToBool() (bool, error)
- func (p *Property) GetToDate() (time.Time, error)
- func (p *Property) GetToDatetime() (time.Time, error)
- func (p *Property) GetToDuration() (time.Duration, error)
- func (p *Property) GetToFloat() (float64, error)
- func (p *Property) GetToInt() (int, error)
- func (p *Property) GetToText() (string, error)
- func (p *Property) GetToTextlines() ([]string, error)
- func (p *Property) SetFromBinary(b []byte)
- func (p *Property) SetFromDatetime(t time.Time)
- func (p *Property) SetFromDuration(d time.Duration)
- func (p *Property) SetFromText(text string)
- func (p *Property) SetFromTextlines(lines []string)
- func (p *Property) UpdateParamValue(vdt string)
- type VAlarm
- type VEvent
- type VFreeBusy
- type VJournal
- type VTZDAYLIGHT
- type VTZSTANDARD
- type VTimezone
- type VTodo
Examples ¶
Constants ¶
const ( Paramaltrep = "ALTREP" Paramcn = "CN" Paramcutype = "CUTYPE" Paramdelfrom = "DELEGATED-FROMx" Paramdelto = "DELEGATED-TO" Paramdir = "DIR" Paramencoding = "ENCODING" Paramfmttype = "FMTTYPE" Paramfbtype = "FBTYPE" Paramlanguage = "LANGUAGE" Parammember = "MEMBER" Parampartstat = "PARTSTAT" Paramrange = "RANGE" Paramtrigrel = "RELATED" Paramreltype = "RELTYPE" Paramrole = "ROLE" Paramrsvp = "RSVP" Paramsentby = "SENT-BY" Paramtzid = "TZID" Paramvaluetypeparam = "VALUE" )
Parameters defined in RFC 5545 3.2
const ( VDTdefault = "" VDTbinary = "BINARY" VDTbool = "BOOL" VDTcalendaraddress = "CAL-ADDRESS" VDTdate = "DATE" VDTdatetime = "DATE-TIME" VDTduration = "DURATION" VDTfloat = "FLOAT" VDTint = "INTEGER" VDTperiod = "PERIOD" VDTrecurrence = "RECUR" VDTtext = "TEXT" VDTtime = "TIME" VDTuri = "URI" VDTutcoffset = "UTC-OFFSET" )
Value types defined in RFC 5545 3.3
const ( PropCalendarScale = "CALSCALE" PropMethod = "METHOD" PropProductIdentifier = "PRODID" PropVersion = "VERSION" )
propertis defined in RFC 5545 3.7
const ( //Descriptive Component Properties PropAttachment = "ATTACH" PropCategories = "CATEGORIES" PropClassification = "CLASS" PropComment = "COMMENT" PropDescription = "DESCRIPTION" PropGeographicPosition = "GEO" PropLocation = "LOCATION" PropPercentComplete = "PERCENT-COMPLETE" PropPriority = "PRIORITY" PropResources = "RESOURCES" PropStatus = "STATUS" PropSummary = "SUMMARY" //Date and Time Component Properties PropDatetimeCompleted = "COMPLETED" PropDatetimeEnd = "DTEND" PropDatetimeDue = "DUE" PropDatetimeStart = "DTSTART" PropDuration = "DURATION" PropFreeBusy = "FREEBUSY" PropTimeTransparency = "TRANSP" //Time Zone Component Properties PropTimeZoneIdentifier = "TZID" PropTimeZoneName = "TZNAME" PropTimeZoneOffsetFrom = "TZOFFSETFROM" PropTimeZoneOffsetTo = "TZOFFSETTO" PropTimeZoneURL = "TZURL" //Relationship Component Properties PropAttendee = "ATTENDEE" PropContact = "CONTACT" PropOrganizer = "ORGANIZER" PropRecurrenceId = "RECURRENCE-ID" PropRelatedTo = "RELATED-TO" PropURL = "URL" PropUID = "UID" //Recurrence Component Properties PropExceptionDatetime = "EXDATE" PropRecurrenceDatetime = "RDATE" PropRecurrenceRule = "RRULE" //Alarm Component Properties PropAction = "ACTION" PropRepeatCount = "REPEAT" PropTrigger = "TRIGGER" //Change Management Component Properties PropDatetimeCreated = "CREATED" PropDatetimeStamp = "DTSTAMP" PropLastModified = "LAST-MODIFIED" PropSequenceNumber = "SEQUENCE" //Request Status PropRequestStatus = "REQUEST-STATUS" )
component properties defined in RFC 3.8
const ( DateFormat = "20060102" DatetimeFormat = "20060102T150405" DatetimeFormat2 = "20060102T150405Z" )
const ( CompCalendar = "VCALENDAR" CompEvent = "VEVENT" CompTodo = "VTODO" CompJournal = "VJOURNAL" CompFreebusy = "VFREEBUSY" CompTimezone = "VTIMEZONE" CompTimezoneStandard = "STANDARD" CompTimezoneDaylight = "DAYLIGHT" CompAlarm = "VALARM" )
RFC 5545 3.6
Variables ¶
var DefaultVDT = map[string]string{ PropCalendarScale: VDTtext, PropMethod: VDTtext, PropProductIdentifier: VDTtext, PropVersion: VDTtext, PropAttachment: VDTuri, PropCategories: VDTtext, PropClassification: VDTtext, PropComment: VDTtext, PropDescription: VDTtext, PropGeographicPosition: VDTfloat, PropLocation: VDTtext, PropPercentComplete: VDTint, PropPriority: VDTint, PropResources: VDTtext, PropStatus: VDTtext, PropSummary: VDTtext, PropDatetimeCompleted: VDTdatetime, PropDatetimeEnd: VDTdatetime, PropDatetimeDue: VDTdatetime, PropDatetimeStart: VDTdatetime, PropDuration: VDTduration, PropFreeBusy: VDTperiod, PropTimeTransparency: VDTtext, PropTimeZoneIdentifier: VDTtext, PropTimeZoneName: VDTtext, PropTimeZoneOffsetFrom: VDTutcoffset, PropTimeZoneOffsetTo: VDTutcoffset, PropTimeZoneURL: VDTuri, PropAttendee: VDTcalendaraddress, PropContact: VDTtext, PropOrganizer: VDTcalendaraddress, PropRecurrenceId: VDTdatetime, PropRelatedTo: VDTtext, PropURL: VDTuri, PropUID: VDTtext, PropExceptionDatetime: VDTdatetime, PropRecurrenceDatetime: VDTdatetime, PropRecurrenceRule: VDTrecurrence, PropAction: VDTtext, PropRepeatCount: VDTint, PropTrigger: VDTduration, PropDatetimeCreated: VDTdatetime, PropDatetimeStamp: VDTdatetime, PropLastModified: VDTdatetime, PropSequenceNumber: VDTint, PropRequestStatus: VDTtext, }
property default vaule data type
var OneOrZeroPropMap = map[string][]string{ CompCalendar: []string{PropCalendarScale, PropMethod}, CompEvent: []string{PropDatetimeStart, PropClassification, PropDatetimeCreated, PropDescription, PropGeographicPosition, PropLastModified, PropLocation, PropOrganizer, PropPriority, PropSequenceNumber, PropStatus, PropSummary, PropTimeTransparency, PropURL, PropRecurrenceId, PropDatetimeEnd, PropDuration}, CompTodo: []string{PropClassification, PropDatetimeCompleted, PropDatetimeCreated, PropDescription, PropDatetimeStart, PropGeographicPosition, PropLastModified, PropLocation, PropOrganizer, PropPercentComplete, PropPriority, PropRecurrenceId, PropSequenceNumber, PropStatus, PropSummary, PropURL, PropDatetimeDue, PropDuration}, CompJournal: []string{PropClassification, PropDatetimeCreated, PropDatetimeStart, PropLastModified, PropOrganizer, PropRecurrenceId, PropSequenceNumber, PropStatus, PropSummary, PropURL}, CompFreebusy: []string{PropContact, PropDatetimeStart, PropDatetimeEnd, PropOrganizer, PropURL}, CompTimezone: []string{PropLastModified, PropTimeZoneURL}, }
var OnlyOnePropMap = map[string][]string{ CompCalendar: []string{PropProductIdentifier, PropVersion}, CompEvent: []string{PropDatetimeStamp, PropUID}, CompTodo: []string{PropDatetimeStamp, PropUID}, CompJournal: []string{PropDatetimeStamp, PropUID}, CompFreebusy: []string{PropDatetimeStamp, PropUID}, CompTimezone: []string{PropTimeZoneIdentifier}, CompTimezoneStandard: []string{PropDatetimeStart, PropTimeZoneOffsetTo, PropTimeZoneOffsetFrom}, CompTimezoneDaylight: []string{PropDatetimeStart, PropTimeZoneOffsetTo, PropTimeZoneOffsetFrom}, CompAlarm: []string{PropAction, PropTrigger}, }
Functions ¶
Types ¶
type Attendee ¶
type Attendee struct {
ComponentObj
}
type Calendar ¶
type Calendar struct {
ComponentObj
}
func NewCalendar ¶
func NewCalendar() *Calendar
func (*Calendar) AddComponent ¶
func (*Calendar) SetDescription ¶
func (*Calendar) SetLastModified ¶
func (*Calendar) SetProductId ¶
func (*Calendar) SetProperty ¶
func (*Calendar) SetVersion ¶
type Component ¶
type Component interface { Name() string Properties() []Property //TODO:prepare for IANA properties RFC 5545 8 SubComponents() []Component IsAvailable() error // contains filtered or unexported methods }
The value for the "component" parameter is defined as follows:
component = "VEVENT" / "VTODO" / "VJOURNAL" / "VFREEBUSY" / "VTIMEZONE" / iana-token / x-name
type ComponentObj ¶
func (*ComponentObj) Name ¶
func (com *ComponentObj) Name() string
func (*ComponentObj) Properties ¶
func (com *ComponentObj) Properties() []Property
func (*ComponentObj) SubComponents ¶
func (com *ComponentObj) SubComponents() []Component
type ContentLine ¶
type ContentLine string
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Example ¶
var r io.Reader dec := NewDecoder(r) for { c, err := dec.Decode() cal := NewCalendar() cal.SubComponentsObj = c.SubComponents() cal.NameObj = c.Name() cal.PropertiesObj = c.Properties() if err == io.EOF { break } else if err != nil { log.Fatal(err) } for _, event := range cal.GetEvents() { props := event.Properties() var summary string for _, p := range props { if p.Name == PropSummary { s, err := p.GetToText() if err != nil { panic(err) } summary = s } } log.Printf("Found event: %v", summary) } }
Output:
func NewDecoder ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Example ¶
event := NewEvent() p := NewProperty(PropUID) p.Value = ToText("uid@example.org") event.PropertiesObj = append(event.PropertiesObj, *p) p = NewProperty(PropDatetimeStamp) p.SetFromDatetime(time.Now()) event.PropertiesObj = append(event.PropertiesObj, *p) p = NewProperty(PropSummary) p.SetFromText("Event Test") event.PropertiesObj = append(event.PropertiesObj, *p) p = NewProperty(PropDatetimeStart) p.SetFromDatetime(time.Now().Add(24 * time.Hour)) cal := NewCalendar() cal.SubComponentsObj = append(cal.SubComponentsObj, event.SubComponents()...) var buf bytes.Buffer if err := NewEncoder(&buf).Encode(cal); err != nil { log.Fatal(err) } log.Print(buf.String())
Output:
func NewEncoder ¶
type ParamItem ¶
all Parameters should implement this interface
func NewParamCN ¶
func NewParamEncoding ¶
func NewParamFMTtype ¶
func NewParamItem ¶
func NewParamRSVP ¶
func NewParamValue ¶
type ParamItemObj ¶
used to store ONE parameter,and implement ParamKeyValues
func (*ParamItemObj) ParamItem ¶
func (p *ParamItemObj) ParamItem(...interface{}) (string, []string)
type Parameters ¶
func (Parameters) Add ¶
func (p Parameters) Add(k, v string)
one ParamItem can have multi values,add one value to an existed ParamItem
func (Parameters) AddItem ¶
func (p Parameters) AddItem(pi ParamItem)
one ParamItem can have multi values,add one value to an existed ParamItem
func (Parameters) Del ¶
func (p Parameters) Del(k string)
func (Parameters) DelItem ¶
func (p Parameters) DelItem(pi ParamItem)
func (Parameters) Get ¶
func (p Parameters) Get(name string) string
func (Parameters) GetItem ¶
func (p Parameters) GetItem(name string) ParamItem
func (Parameters) Set ¶
func (p Parameters) Set(k, v string)
func (Parameters) SetItem ¶
func (p Parameters) SetItem(pi ParamItem)
type Property ¶
type Property struct { Name string Params Parameters Value string }
=============================Property======================================
a property is a contentline in icalendar object contentline = name *(";" param ) ":" value CRLF one name none/one/multi parameters,parameters is key-value one value
func NewProperty ¶
func (*Property) GetParamValue ¶
func (*Property) GetToFloat ¶
func (*Property) GetToTextlines ¶
func (*Property) SetFromBinary ¶
func (*Property) SetFromDatetime ¶
func (*Property) SetFromDuration ¶
func (*Property) SetFromText ¶
func (*Property) SetFromTextlines ¶
func (*Property) UpdateParamValue ¶
type VAlarm ¶
type VAlarm struct {
ComponentObj
}
type VEvent ¶
type VEvent struct {
ComponentObj
}
type VFreeBusy ¶
type VFreeBusy struct {
ComponentObj
}
type VJournal ¶
type VJournal struct {
ComponentObj
}
type VTZDAYLIGHT ¶
type VTZDAYLIGHT struct {
ComponentObj
}
type VTZSTANDARD ¶
type VTZSTANDARD struct {
ComponentObj
}
type VTimezone ¶
type VTimezone struct {
ComponentObj
}
type VTodo ¶
type VTodo struct {
ComponentObj
}