Documentation
¶
Overview ¶
Package ical defines an iCalendar, a calendar of events and tasks, which is encoded and decoded as iCalendar 2.0, and its images, which can be embedded in it, as artwork. Reference: https://www.rfc-editor.org/rfc/rfc5545
Index ¶
Constants ¶
const ( // ContentType is the content type of an iCalendar ContentType = "text/calendar" // TaskType and EventType are the content types of an iCalendar whose // components are all tasks, VTODO, or all events, VEVENT, with the // component parameter of RFC 5545, so a client can tell them apart // without reading them TaskType = ContentType + "; component=VTODO" EventType = ContentType + "; component=VEVENT" )
const (
// DefaultProdID is the product which writes a calendar without one
DefaultProdID = "-//mutablelogic//go-metadata//EN"
)
const ( // MaxLineSize is the longest line which is read, once it's unfolded, // which includes an image of several megabytes, as base64 MaxLineSize = 16 << 20 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Calendar ¶
type Calendar struct {
ProdID string `json:"prodid,omitempty"` // The product which wrote it
Name string `json:"name,omitempty"` // Its name, such as Birthdays
Description string `json:"description,omitempty"` // Its description
TZ string `json:"tz,omitempty"` // Its zone, such as Europe/Berlin
Image *Image `json:"image,omitempty"` // Its image, embedded or linked
Events []*Event `json:"events,omitempty"` // Its events and tasks
}
Calendar is a calendar of events and tasks
func Decode ¶
Decode returns the calendar of r, which is iCalendar 2.0, with its events and tasks, without its other components, such as alarms and zones, or an empty calendar when there's none. An event without a start, or a task without a start or when it's due, isn't returned. When a calendar has more than one VCALENDAR, they're one calendar.
func (*Calendar) ContentType ¶ added in v1.1.5
ContentType returns the content type of the calendar: TaskType when its components are all tasks, EventType when they're all events, or else ContentType, when they're both, or it has none
func (*Calendar) MarshalText ¶
MarshalText returns the calendar as iCalendar 2.0 (see Encoder.Encode)
func (*Calendar) UnmarshalText ¶
UnmarshalText sets the calendar from iCalendar 2.0 (see Decode)
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes calendars as iCalendar 2.0
func NewEncoder ¶
NewEncoder returns an encoder of calendars to w
func (*Encoder) Encode ¶
Encode writes the calendar as iCalendar 2.0, with its name and description as Apple's and Google's X-WR-CALNAME and X-WR-CALDESC, which calendars read, and its events and tasks. An event's stamp, which it must have, is the Unix epoch when it isn't set, so a calendar is the same each time it's written. A time in a zone is written with its TZID, without the zone's definition, which calendars which know the zone don't need. Values which are empty aren't written.
type Event ¶
type Event struct {
Kind Kind `json:"kind"` // event or task
UID string `json:"uid,omitempty"` // Its unique identifier
Summary string `json:"summary,omitempty"` // Its title
Description string `json:"description,omitempty"` // Its description
Location string `json:"location,omitempty"` // Where it is
Geo *geo.LatLong `json:"geo,omitempty"` // The position of where it is
URL string `json:"url,omitempty"` // A link about it
Start Time `json:"start,omitzero"` // When it starts
End Time `json:"end,omitzero"` // When it ends, which is exclusive
Due Time `json:"due,omitzero"` // When a task is due
Completed time.Time `json:"completed,omitzero"` // When a task was completed
Parent string `json:"parent,omitempty"` // The UID of a task's parent, of which it's a subtask
RRule string `json:"rrule,omitempty"` // How it repeats, such as FREQ=YEARLY
ExDates []Time `json:"exdates,omitempty"` // The starts of a repeating event which it excludes
RecurrenceID Time `json:"recurrence_id,omitzero"` // The start of an occurrence it changes
Status string `json:"status,omitempty"` // Such as CONFIRMED or CANCELLED
Organizer string `json:"organizer,omitempty"` // The email address of its organizer
Attendees []string `json:"attendees,omitempty"` // The email addresses of its attendees
Categories []string `json:"categories,omitempty"` // Its categories, such as Birthdays
Transparent bool `json:"transparent,omitempty"` // Whether it doesn't make its time busy
Image *Image `json:"image,omitempty"` // Its image, embedded or linked
OmitYear int `json:"omit_year,omitempty"` // The year of a start whose year isn't known, such as 1604 for a birthday
Stamp time.Time `json:"stamp,omitzero"` // When it was written
Created time.Time `json:"created,omitzero"` // When it was created
Modified time.Time `json:"last_modified,omitzero"` // When it was last changed
}
Event is an event, or a task, of a calendar
type Image ¶
type Image struct {
MediaType string `json:"media_type,omitempty"`
Data []byte `json:"data,omitempty"`
URI string `json:"uri,omitempty"`
Display string `json:"display,omitempty"`
}
Image is the image of a calendar or an event, which is embedded, as its data and its media type, such as image/png, or linked, as a URI, with how it's displayed, such as BADGE or GRAPHIC Reference: https://www.rfc-editor.org/rfc/rfc7986#section-5.10
type Time ¶
type Time struct {
Time time.Time `json:"time"`
Date bool `json:"date,omitempty"` // A date, without a time
TZID string `json:"tzid,omitempty"` // The zone of a time
Floating bool `json:"floating,omitempty"` // A time without a zone, or in one which isn't known
}
Time is a date, or a time, which is in UTC, in a zone, by its TZID, such as Europe/Berlin, or floating, which is the same time in every zone, as is a time in a zone which isn't known, such as a Windows zone