ics

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ics reads iCalendar (RFC 5545) data into busy time. It is a deliberately small reader, not a full implementation: it understands VEVENT with DTSTART/DTEND/DURATION, IANA TZIDs (resolved via the Go time zone database), all-day events, EXDATE, and DAILY/WEEKLY recurrence with INTERVAL, COUNT, UNTIL, and BYDAY. Unsupported recurrence frequencies fall back to the first occurrence only. That covers the overwhelming share of real calendar feeds — every major provider exports a secret iCal URL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode added in v0.2.0

func Encode(w io.Writer, method string, events []Event) error

Encode writes events as an iCalendar stream suitable for a CalDAV PUT or an email invitation. method is the iTIP METHOD ("REQUEST" for invites, "" to omit). Events need UID and Start/End set; Stamp defaults to Start.

func NewUID added in v0.2.0

func NewUID() string

NewUID returns a random globally unique event identifier.

Types

type Attendee added in v0.2.0

type Attendee struct {
	Name  string // CN parameter
	Email string
}

Attendee is an ORGANIZER or ATTENDEE participant.

type Calendar

type Calendar struct {
	Name   string
	Events []Event
}

Calendar is a parsed feed.

func Parse

func Parse(r io.Reader) (*Calendar, error)

Parse reads an iCalendar stream. Floating (zone-less) times are interpreted in UTC; pass a calendar default via ParseIn if you need otherwise.

func ParseIn

func ParseIn(r io.Reader, floating *time.Location) (*Calendar, error)

ParseIn is Parse with an explicit zone for floating times.

func (*Calendar) Busy

func (c *Calendar) Busy(window interval.Span) interval.Set

Busy expands every opaque, non-cancelled event within the window into a normalized busy set.

func (*Calendar) OccurrencesIn added in v0.2.0

func (c *Calendar) OccurrencesIn(window interval.Span) []Occurrence

OccurrencesIn expands every non-cancelled event (including transparent ones — an agenda still shows them) into concrete instances overlapping the window, sorted by start time.

type Event

type Event struct {
	UID         string
	Summary     string
	Location    string
	Description string
	URL         string
	Start       time.Time
	End         time.Time
	Stamp       time.Time // DTSTAMP; used when encoding
	AllDay      bool
	Transparent bool // TRANSP:TRANSPARENT — shows as free
	Cancelled   bool
	Organizer   Attendee
	Attendees   []Attendee
	Recur       *Recurrence
	ExDates     []time.Time
}

Event is one VEVENT, recurrence not yet expanded.

func (Event) Occurrences

func (ev Event) Occurrences(window interval.Span) []interval.Span

Occurrences expands the event's recurrence into concrete spans overlapping the window.

type Occurrence added in v0.2.0

type Occurrence struct {
	Start, End time.Time
	Event      Event
}

Occurrence is one concrete instance of an event.

type Recurrence

type Recurrence struct {
	Freq     string // "DAILY" or "WEEKLY"; anything else: first occurrence only
	Interval int
	Count    int
	Until    time.Time
	ByDay    []time.Weekday
}

Recurrence is the supported subset of RRULE.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL