Documentation ¶
Overview ¶
Package ical implements the iCalendar file format.
iCalendar is defined in RFC 5545.
Index ¶
- Constants
- type Calendar
- type Component
- type ConferenceFeature
- type Decoder
- type Encoder
- type Event
- type EventStatus
- type ImageDisplay
- type Params
- type Prop
- func (prop *Prop) Binary() ([]byte, error)
- func (prop *Prop) Bool() (bool, error)
- func (prop *Prop) DateTime(loc *time.Location) (time.Time, error)
- func (prop *Prop) Duration() (time.Duration, error)
- func (prop *Prop) Float() (float64, error)
- func (prop *Prop) Int() (int, error)
- func (prop *Prop) SetBinary(b []byte)
- func (prop *Prop) SetDate(t time.Time)
- func (prop *Prop) SetDateTime(t time.Time)
- func (prop *Prop) SetDuration(dur time.Duration)
- func (prop *Prop) SetText(text string)
- func (prop *Prop) SetTextList(l []string)
- func (prop *Prop) SetURI(u *url.URL)
- func (prop *Prop) SetValueType(t ValueType)
- func (prop *Prop) Text() (string, error)
- func (prop *Prop) TextList() ([]string, error)
- func (prop *Prop) URI() (*url.URL, error)
- func (prop *Prop) ValueType() ValueType
- type Props
- func (props Props) Add(prop *Prop)
- func (props Props) DateTime(name string, loc *time.Location) (time.Time, error)
- func (props Props) Del(name string)
- func (props Props) Get(name string) *Prop
- func (props Props) RecurrenceRule() (*rrule.ROption, error)
- func (props Props) Set(prop *Prop)
- func (props Props) SetDate(name string, t time.Time)
- func (props Props) SetDateTime(name string, t time.Time)
- func (props Props) SetRecurrenceRule(rule *rrule.ROption)
- func (props Props) SetText(name, text string)
- func (props Props) SetURI(name string, u *url.URL)
- func (props Props) Text(name string) (string, error)
- func (props Props) URI(name string) (*url.URL, error)
- func (props Props) Values(name string) []Prop
- type ValueType
Examples ¶
Constants ¶
const ( CompCalendar = "VCALENDAR" CompEvent = "VEVENT" CompToDo = "VTODO" CompJournal = "VJOURNAL" CompFreeBusy = "VFREEBUSY" CompTimezone = "VTIMEZONE" CompAlarm = "VALARM" )
Components as defined in RFC 5545 section 3.6.
const ( CompTimezoneStandard = "STANDARD" CompTimezoneDaylight = "DAYLIGHT" )
Timezone components.
const ( // Calendar properties PropCalendarScale = "CALSCALE" PropMethod = "METHOD" PropProductID = "PRODID" PropVersion = "VERSION" PropName = "NAME" PropRefreshInterval = "REFRESH-INTERVAL" PropSource = "SOURCE" // Component properties PropAttach = "ATTACH" PropCategories = "CATEGORIES" PropClass = "CLASS" PropComment = "COMMENT" PropDescription = "DESCRIPTION" PropGeo = "GEO" PropLocation = "LOCATION" PropPercentComplete = "PERCENT-COMPLETE" PropPriority = "PRIORITY" PropResources = "RESOURCES" PropStatus = "STATUS" PropSummary = "SUMMARY" PropColor = "COLOR" PropImage = "IMAGE" // Date and time component properties PropCompleted = "COMPLETED" PropDateTimeEnd = "DTEND" PropDue = "DUE" PropDateTimeStart = "DTSTART" PropDuration = "DURATION" PropFreeBusy = "FREEBUSY" PropTransparency = "TRANSP" // Timezone component properties PropTimezoneID = "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" PropConference = "CONFERENCE" // Recurrence component properties PropExceptionDates = "EXDATE" PropRecurrenceDates = "RDATE" PropRecurrenceRule = "RRULE" // Alarm component properties PropAction = "ACTION" PropRepeat = "REPEAT" PropTrigger = "TRIGGER" // Change management component properties PropCreated = "CREATED" PropDateTimeStamp = "DTSTAMP" PropLastModified = "LAST-MODIFIED" PropSequence = "SEQUENCE" // Miscellaneous component properties PropRequestStatus = "REQUEST-STATUS" )
Properties as defined in RFC 5545 section 3.7, RFC 5545 section 3.8 and RFC 7986 section 5.
const ( ParamAltRep = "ALTREP" ParamCommonName = "CN" ParamCalendarUserType = "CUTYPE" ParamDelegatedFrom = "DELEGATED-FROM" ParamDelegatedTo = "DELEGATED-TO" ParamDir = "DIR" ParamEncoding = "ENCODING" ParamFormatType = "FMTTYPE" ParamFreeBusyType = "FBTYPE" ParamLanguage = "LANGUAGE" ParamMember = "MEMBER" ParamParticipationStatus = "PARTSTAT" ParamRange = "RANGE" ParamRelated = "RELATED" ParamRelationshipType = "RELTYPE" ParamRole = "ROLE" ParamRSVP = "RSVP" ParamSentBy = "SENT-BY" ParamTimezoneID = "TZID" ParamValue = "VALUE" ParamDisplay = "DISPLAY" ParamEmail = "EMAIL" ParamFeature = "FEATURE" ParamLabel = "LABEL" )
Property parameters as defined in RFC 5545 section 3.2 and RFC 7986 section 6.
const ( MIMEType = "text/calendar" Extension = "ics" )
MIME type and file extension for iCal, defined in RFC 5545 section 8.1.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
Component is an iCalendar component: collections of properties that express a particular calendar semantic. A components can be an events, a to-do, a journal entry, timezone information, free/busy time information, or an alarm.
func NewComponent ¶
NewComponent creates a new component with the specified name.
type ConferenceFeature ¶
type ConferenceFeature string
ConferenceFeature describes features of a conference. Defined in RFC 7986 section 5.7.
const ( ConferenceAudio ConferenceFeature = "AUDIO" ConferenceChat ConferenceFeature = "CHAT" ConferenceFeed ConferenceFeature = "FEED" ConferenceModerator ConferenceFeature = "MODERATOR" ConferencePhone ConferenceFeature = "PHONE" ConferenceScreen ConferenceFeature = "SCREEN" ConferenceVideo ConferenceFeature = "VIDEO" )
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Example ¶
// Let's assume r is an io.Reader containing iCal data var r io.Reader dec := ical.NewDecoder(r) for { cal, err := dec.Decode() if err == io.EOF { break } else if err != nil { log.Fatal(err) } for _, event := range cal.Events() { summary, err := event.Props.Text(ical.PropSummary) if err != nil { log.Fatal(err) } log.Printf("Found event: %v", summary) } }
Output:
func NewDecoder ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Example ¶
event := ical.NewEvent() event.Props.SetText(ical.PropUID, "uid@example.org") event.Props.SetDateTime(ical.PropDateTimeStamp, time.Now()) event.Props.SetText(ical.PropSummary, "My awesome event") event.Props.SetDateTime(ical.PropDateTimeStart, time.Now().Add(24*time.Hour)) cal := ical.NewCalendar() cal.Props.SetText(ical.PropVersion, "2.0") cal.Props.SetText(ical.PropProductID, "-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN") cal.Children = append(cal.Children, event.Component) var buf bytes.Buffer if err := ical.NewEncoder(&buf).Encode(cal); err != nil { log.Fatal(err) } log.Print(buf.String())
Output:
func NewEncoder ¶
type Event ¶
type Event struct {
*Component
}
Event represents a scheduled amount of time on a calendar.
func (*Event) DateTimeEnd ¶
DateTimeEnd returns the non-inclusive end of the event.
func (*Event) DateTimeStart ¶
DateTimeStart returns the inclusive start of the event.
func (*Event) SetStatus ¶
func (e *Event) SetStatus(status EventStatus)
func (*Event) Status ¶
func (e *Event) Status() (EventStatus, error)
type EventStatus ¶
type EventStatus string
const ( EventTentative EventStatus = "TENTATIVE" EventConfirmed EventStatus = "CONFIRMED" EventCancelled EventStatus = "CANCELLED" )
type ImageDisplay ¶
type ImageDisplay string
ImageDisplay describes the way an image for a component can be displayed. Defined in RFC 7986 section 6.1.
const ( ImageBadge ImageDisplay = "BADGE" ImageGraphic ImageDisplay = "GRAPHIC" ImageFullSize ImageDisplay = "FULLSIZE" ImageThumbnail ImageDisplay = "THUMBNAIL" )
type Prop ¶
Prop is a component property.
func (*Prop) SetDateTime ¶
func (*Prop) SetDuration ¶
func (*Prop) SetTextList ¶
func (*Prop) SetValueType ¶
type Props ¶
Props is a set of component properties.
func (Props) RecurrenceRule ¶
Returns an ROption based on the events RRULE.
This object can then be used to construct `RRule` instances for different fields, for example, an rrule based on `DTSTART`:
roption, err := props.RecurrenceRule() if err != nil { log.Fatalf("error parsing rrule:", err) } if roption == nil { log.Fatalf("props have no RRULE") } dtstart, err := props.DateTime("DTSTART", nil) if err != nil { log.Fatalf("error parsing dtstart:", err) } roption.Dtstart = dtstart return rrule.NewRRule(*roption)
This object can then be used to calculate the `DTSTART` of all recurrances.
func (Props) SetRecurrenceRule ¶
func (props Props) SetRecurrenceRule(rule *rrule.ROption)
type ValueType ¶
type ValueType string
ValueType is the type of a property.
const ( ValueDefault ValueType = "" ValueBinary ValueType = "BINARY" ValueBool ValueType = "BOOLEAN" ValueCalendarAddress ValueType = "CAL-ADDRESS" ValueDate ValueType = "DATE" ValueDateTime ValueType = "DATE-TIME" ValueDuration ValueType = "DURATION" ValueFloat ValueType = "FLOAT" ValueInt ValueType = "INTEGER" ValuePeriod ValueType = "PERIOD" ValueRecurrence ValueType = "RECUR" ValueText ValueType = "TEXT" ValueTime ValueType = "TIME" ValueURI ValueType = "URI" ValueUTCOffset ValueType = "UTC-OFFSET" )
Value types as defined in RFC 5545 section 3.3.