Help us shape the future of Go! Take the 2026 Go Developer Survey

ics

package module
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 159

README

golang-ical

golang-ical logo

An ICS / ICal parser and serialiser for Golang.

GoDoc

Because the other libraries didn't quite do what I needed.

Parsing Calendars

Usage, parsing:

import (
    "strings"

    ics "github.com/arran4/golang-ical"
)
cal, err := ics.ParseCalendar(strings.NewReader(input))

Usage, parsing from a URL:

cal, err := ics.ParseCalendarFromUrl("https://your-ics-url")

Creating Calendars

Usage, creating a calendar:

cal := ics.NewCalendar()
cal.SetMethod(ics.MethodRequest)
event := cal.AddEvent(fmt.Sprintf("id@domain", p.SessionKey.IntID()))
event.SetCreatedTime(time.Now())
event.SetDtStampTime(time.Now())
event.SetModifiedAt(time.Now())
event.SetStartAt(time.Now())
event.SetEndAt(time.Now())
event.SetSummary("Summary")
event.SetLocation("Address")
event.SetDescription("Description")
event.SetURL("https://URL/")
event.AddRrule(fmt.Sprintf("FREQ=YEARLY;BYMONTH=%d;BYMONTHDAY=%d", time.Now().Month(), time.Now().Day()))
event.SetOrganizer("sender@domain", ics.WithCN("This Machine"))
event.AddAttendee("receiver or participant", ics.CalendarUserTypeIndividual, ics.ParticipationStatusNeedsAction, ics.ParticipationRoleReqParticipant, ics.WithRSVP(true))
return cal.Serialize()

Helper methods created as needed feel free to send a P.R. with more.

You can also construct a calendar with options:

cal, err := ics.NewCalendarWithOptions(
    ics.WithVersion("2.0"),
    ics.WithProductId("-//my-service//Golang ICS Library"),
)

When to use which constructor:

  • Use NewCalendar() for the default metadata:
    • VERSION:2.0
    • PRODID:-//arran4//Golang ICS Library
  • Use NewCalendarFor(service) when you want the same defaults but a service-specific PRODID without building options manually.
    • It sets VERSION:2.0.
    • It sets PRODID:-//<service>//Golang ICS Library.
    • Example: ics.NewCalendarFor("my-team") yields PRODID:-//my-team//Golang ICS Library.
  • Use NewCalendarWithOptions(...) when you need full control at construction time (for example custom WithVersion(...) or custom WithProductId(...)).

Use NewCalendarFor(service) when you publish ICS from multiple applications/tenants and want each feed to identify its producer via PRODID while still using library defaults.

Adding Reminders (VALARM)

To attach a reminder/alarm to an event, create a VALARM component and add it to the event:

event := cal.AddEvent("event-uid@domain")
event.SetSummary("Team meeting")
event.SetStartAt(time.Now())
event.SetEndAt(time.Now().Add(time.Hour))

alarm := ics.NewAlarm("") // the string arg is unused for VALARM (no UID property per RFC 5545)
alarm.SetAction(ics.ActionDisplay)
alarm.SetTrigger("-PT15M") // fires 15 minutes before DTSTART
alarm.SetDescription("Team meeting starting soon")
event.AddVAlarm(alarm)

Note on DISPLAY alarms: per RFC 5545 §3.6.6, a DISPLAY alarm's required properties are ACTION, DESCRIPTION, and TRIGGER — not SUMMARY. SUMMARY only applies to EMAIL-action alarms, where it's used as the message subject. Most calendar clients (Google Calendar, Apple Calendar, Outlook) read DESCRIPTION to render the alarm's message text, so make sure to call SetDescription(...) — calling only SetSummary(...) will produce a valid but silent reminder in many clients.

TRIGGER takes an ISO-8601 duration relative to the event's start; a negative duration fires before the start (e.g. -PT15M = 15 minutes before, -PT2H = 2 hours before).

Important Note on Line Endings (RFC 5545 Compliance)

By default, .Serialize() uses Unix-style line endings (LF). To strictly comply with the iCalendar specification (RFC 5545), which requires Windows-style line endings (CRLF) for broad compatibility with email and calendar clients like Outlook and Apple Calendar, pass the explicit formatting option:

return cal.Serialize(ics.WithNewLineWindows)

Parsing malformed properties (strict/skip/recover)

By default, parsing is strict and returns an error for malformed content lines.

cal, err := ics.ParseCalendar(reader)

For real-world feeds with malformed properties, use ParseCalendarWithOptions and provide a custom property parser.

Pre-built parser helpers are included:

  • SkipPropertyParser: ignore malformed lines.
  • FallbackParser(LooseParser): try strict parsing first, then recover by keeping token/value.

Skip malformed properties:

cal, err := ics.ParseCalendarWithOptions(reader,
    ics.WithPropertyParser(ics.SkipPropertyParser),
)

Recover malformed properties by keeping token + value (dropping malformed params):

cal, err := ics.ParseCalendarWithOptions(reader,
    ics.WithPropertyParser(ics.FallbackParser(ics.LooseParser)),
)

Custom parser behavior:

import (
    "fmt"
    "strings"

    ics "github.com/arran4/golang-ical"
)

parser := func(rawLine ics.ContentLine) (*ics.BaseProperty, error) {
    // Try strict parsing first.
    line, err := ics.ParseProperty(rawLine)
    if err == nil {
        return line, nil
    }

    // Skip specific lines and continue.
    if strings.Contains(string(rawLine), "X-TKF-") {
        return nil, fmt.Errorf("%w: skipping Tockify extension", ics.ErrPropertySkipped)
    }

    // Abort for everything else.
    return nil, err
}

cal, err := ics.ParseCalendarWithOptions(reader, parser)

Notes:

  • ErrPropertySkipped means "ignore this line and continue".
  • Returning (nil, nil) from a parser also skips the line.
  • WithPropertyParser(...) and passing a parser directly to ParseCalendarWithOptions(...) are equivalent.
  • The same parser is used for nested components (for example, malformed properties inside VALARM).
  • Invalid option types return an error wrapped with ErrInvalidOpArg.

Working with Recurring Events

This library parses and provides typed access to recurrence properties (RRULE, RDATE, EXDATE, EXRULE, RECURRENCE-ID) but does not expand them into concrete occurrence dates. This keeps the library dependency-free and lets callers choose their own expansion strategy.

Accessing recurrence properties
  // Parse RRULE into a structured type
  rules, err := event.GetRRules()
  for _, rule := range rules {
      fmt.Println(rule.Freq)       // e.g. ics.FrequencyYearly
      fmt.Println(rule.ByMonth)    // e.g. [10]
      fmt.Println(rule.ByDay)      // e.g. [{OrdWeek:-1 Day:SU}]
      fmt.Println(rule.Count)      // e.g. 10
      fmt.Println(rule.Interval)   // e.g. 1
  }

  // Get excluded dates (handles comma-separated values and multiple properties)
  exDates, err := event.GetExDates()    // []time.Time
  rDates, err := event.GetRDates()      // []time.Time

  // Get recurrence ID (for modified/cancelled occurrences)
  recID, err := event.GetRecurrenceID() // time.Time

  // Serialize a RecurrenceRule back to RRULE format
  rule, _ := ics.ParseRecurrenceRule("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE,FR")
  fmt.Println(rule.String()) // "FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE,FR"
Expanding occurrences with rrule-go

To expand recurring events into concrete dates, use a library like rrule-go:

  import (
      ics "github.com/arran4/golang-ical"
      "github.com/teambition/rrule-go"
  )

  // Parse your calendar
  cal, _ := ics.ParseCalendar(reader)

  for _, event := range cal.Events() {
      dtstart, _ := event.GetStartAt()
      dtend, _ := event.GetEndAt()
      duration := dtend.Sub(dtstart)

      // Build an RRuleSet from the event's recurrence properties
      set := &rrule.Set{}

      rules, _ := event.GetRRules()
      for _, r := range rules {
          rr, _ := rrule.StrToRRule(r.String())
          rr.DTStart(dtstart)
          set.RRule(rr)
      }

      rDates, _ := event.GetRDates()
      for _, rd := range rDates {
          set.RDate(rd)
      }

      exDates, _ := event.GetExDates()
      for _, exd := range exDates {
          set.ExDate(exd)
      }

      // Get all occurrences in a time range
      occurrences := set.Between(rangeStart, rangeEnd, true)

      // Each occurrence is a start time; compute the end from the original duration
      for _, occ := range occurrences {
          fmt.Printf("  %s to %s\n", occ, occ.Add(duration))
      }
  }
Handling RECURRENCE-ID overrides

Calendar feeds use RECURRENCE-ID to modify or cancel individual occurrences of a recurring event. These appear as separate VEVENTs with the same UID but a RECURRENCE-ID property indicating which occurrence they replace.

  type overrideKey struct {
      UID   string
      Start time.Time
  }

  overrides := map[overrideKey]*ics.VEvent{}
  var regularEvents []*ics.VEvent

  for _, event := range cal.Events() {
      recID, err := event.GetRecurrenceID()
      if err == nil {
          uid := event.GetProperty(ics.ComponentPropertyUniqueId).Value
          overrides[overrideKey{UID: uid, Start: recID}] = event
      } else {
          regularEvents = append(regularEvents, event)
      }
  }

  // After expanding occurrences from regularEvents, check each generated
  // occurrence against the overrides map. If a match is found, replace that
  // occurrence with the override's times/properties (or remove it if the
  // override represents a cancellation).

Notice

Looking for a co-maintainer.

Documentation

Index

Constants

View Source
const (
	ComponentPropertyUniqueId        = ComponentProperty(PropertyUid) // TEXT
	ComponentPropertyDtstamp         = ComponentProperty(PropertyDtstamp)
	ComponentPropertyOrganizer       = ComponentProperty(PropertyOrganizer)
	ComponentPropertyAttendee        = ComponentProperty(PropertyAttendee)
	ComponentPropertyAttach          = ComponentProperty(PropertyAttach)
	ComponentPropertyDescription     = ComponentProperty(PropertyDescription) // TEXT
	ComponentPropertyCategories      = ComponentProperty(PropertyCategories)  // TEXT
	ComponentPropertyClass           = ComponentProperty(PropertyClass)       // TEXT
	ComponentPropertyColor           = ComponentProperty(PropertyColor)       // TEXT
	ComponentPropertyCreated         = ComponentProperty(PropertyCreated)
	ComponentPropertySummary         = ComponentProperty(PropertySummary) // TEXT
	ComponentPropertyDtStart         = ComponentProperty(PropertyDtstart)
	ComponentPropertyDtEnd           = ComponentProperty(PropertyDtend)
	ComponentPropertyLocation        = ComponentProperty(PropertyLocation) // TEXT
	ComponentPropertyStatus          = ComponentProperty(PropertyStatus)   // TEXT
	ComponentPropertyFreebusy        = ComponentProperty(PropertyFreebusy)
	ComponentPropertyLastModified    = ComponentProperty(PropertyLastModified)
	ComponentPropertyUrl             = ComponentProperty(PropertyUrl)
	ComponentPropertyGeo             = ComponentProperty(PropertyGeo)
	ComponentPropertyTransp          = ComponentProperty(PropertyTransp)
	ComponentPropertySequence        = ComponentProperty(PropertySequence)
	ComponentPropertyExdate          = ComponentProperty(PropertyExdate)
	ComponentPropertyExrule          = ComponentProperty(PropertyExrule)
	ComponentPropertyRdate           = ComponentProperty(PropertyRdate)
	ComponentPropertyRrule           = ComponentProperty(PropertyRrule)
	ComponentPropertyAction          = ComponentProperty(PropertyAction)
	ComponentPropertyTrigger         = ComponentProperty(PropertyTrigger)
	ComponentPropertyPriority        = ComponentProperty(PropertyPriority)
	ComponentPropertyResources       = ComponentProperty(PropertyResources)
	ComponentPropertyCompleted       = ComponentProperty(PropertyCompleted)
	ComponentPropertyDue             = ComponentProperty(PropertyDue)
	ComponentPropertyPercentComplete = ComponentProperty(PropertyPercentComplete)
	ComponentPropertyTzid            = ComponentProperty(PropertyTzid)
	ComponentPropertyComment         = ComponentProperty(PropertyComment)
	ComponentPropertyRelatedTo       = ComponentProperty(PropertyRelatedTo)
	ComponentPropertyMethod          = ComponentProperty(PropertyMethod)
	ComponentPropertyRecurrenceId    = ComponentProperty(PropertyRecurrenceId)
	ComponentPropertyDuration        = ComponentProperty(PropertyDuration)
	ComponentPropertyContact         = ComponentProperty(PropertyContact)
	ComponentPropertyRequestStatus   = ComponentProperty(PropertyRequestStatus)
	ComponentPropertyRDate           = ComponentProperty(PropertyRdate)
)
View Source
const (
	NewLine = WithNewLineUnix
)

Variables

View Source
var (
	// ErrUnexpectedParamValueLength reports a truncated parameter value.
	ErrUnexpectedParamValueLength = errors.New("unexpected end of param value")

	// ErrExpectedVCalendar reports a VCALENDAR token appearing where another token was expected.
	ErrExpectedVCalendar = errors.New("expected a vcalendar")
	// ErrExpectedBegin reports a missing BEGIN token.
	ErrExpectedBegin = errors.New("expected begin")
	// ErrExpectedEnd reports a missing END token.
	ErrExpectedEnd = errors.New("expected a end")
	// ErrExpectedBeginOrEnd reports a token where either BEGIN or END was expected.
	ErrExpectedBeginOrEnd = errors.New("expected begin or end")
	// ErrUnexpectedCalendarEnd reports an END token that appears after the calendar has already ended.
	ErrUnexpectedCalendarEnd = errors.New("unexpected end")
	// ErrBadCalendarState reports an invalid parser state.
	ErrBadCalendarState = errors.New("bad state")
	// ErrVCalendarNotWhereExpected reports a nested VCALENDAR token.
	ErrVCalendarNotWhereExpected = errors.New("vcalendar not where expected")

	// ErrMissingPropertyParamOperator reports a property parameter missing its `=` separator.
	ErrMissingPropertyParamOperator = errors.New("missing property param operator")
	// ErrUnexpectedEndOfProperty reports a property line that ends before the value is complete.
	ErrUnexpectedEndOfProperty = errors.New("unexpected end of property")

	// ErrStartOrEndNotYetDefined reports a missing start or end time.
	ErrStartOrEndNotYetDefined = errors.New("start or end not yet defined")
	// ErrPropertyNotFound reports that a requested property was not set.
	ErrPropertyNotFound = errors.New("property not found")
	// ErrExpectedOneTZID reports an invalid number of TZID parameters.
	ErrExpectedOneTZID = errors.New("expected one TZID")

	// ErrTimeValueNotMatched reports a timestamp that does not match the parser's supported formats.
	ErrTimeValueNotMatched = errors.New("time value not matched")
	// ErrTimeValueMatchedButUnsupportedAllDayTimeStamp reports an all-day timestamp shape that is not supported.
	ErrTimeValueMatchedButUnsupportedAllDayTimeStamp = errors.New("time value matched but unsupported all-day timestamp")
	// ErrTimeValueMatchedButNotSupported reports a recognized timestamp shape that still cannot be parsed.
	ErrTimeValueMatchedButNotSupported = errors.New("time value matched but not supported")

	// ErrParsingComponentProperty reports a failure while parsing a component property.
	ErrParsingComponentProperty = errors.New("parsing component property")
	// ErrParsingComponentLine reports a failure while parsing a component line.
	ErrParsingComponentLine = errors.New("parsing component line")
	// ErrParsingLine reports a failure while parsing a calendar content line.
	ErrParsingLine = errors.New("parsing line")
	// ErrParsingCalendarLine reports a failure while parsing a calendar line.
	ErrParsingCalendarLine = errors.New("parsing calendar line")
	// ErrParsingProperty reports a failure while parsing a property.
	ErrParsingProperty = errors.New("parsing property")
	// ErrParse reports a generic parse failure.
	ErrParse = errors.New("parse error")

	// ErrMissingPropertyValue reports a property parameter missing its value.
	ErrMissingPropertyValue = errors.New("missing property value")

	// ErrUnexpectedASCIIChar reports a disallowed ASCII control character.
	ErrUnexpectedASCIIChar = errors.New("unexpected char ascii")
	// ErrUnexpectedDoubleQuoteInPropertyParamValue reports an invalid quote in a parameter value.
	ErrUnexpectedDoubleQuoteInPropertyParamValue = errors.New("unexpected double quote in property param value")

	// ErrUnbalancedEnd reports a closing token that does not match the current component.
	ErrUnbalancedEnd = errors.New("unbalanced end")
	// ErrOutOfLines reports that the parser ran out of content lines.
	ErrOutOfLines = errors.New("ran out of lines")
	// ErrComponentNestingTooDeep reports that nested components exceeded the maximum allowed depth.
	ErrComponentNestingTooDeep = errors.New("component nesting too deep")
	// ErrorPropertyNotFound reports that a requested property was not found.
	ErrorPropertyNotFound = errors.New("property not found")

	// ErrInvalidOpArg marks an invalid variadic option argument.
	ErrInvalidOpArg = errors.New("invalid option argument")
	// ErrNilStartLine reports that a parser was called without a starting line.
	ErrNilStartLine = errors.New("nil start line")

	// ErrPropertySkipped marks a parser decision to skip a malformed line and continue.
	ErrPropertySkipped = errors.New("property skipped")
)

Functions

func AcceptUnknownPropertyHandler added in v0.3.3

func AcceptUnknownPropertyHandler(cal *Calendar, state string, cl *BaseProperty) error

AcceptUnknownPropertyHandler allows properties between components (non-standard but occurs in real-world ICS files) These properties are added to the calendar properties list

func DefaultUnknownCalendarPropertyHandler added in v0.3.3

func DefaultUnknownCalendarPropertyHandler(cal *Calendar, state string, cl *BaseProperty) error

func FromText

func FromText(s string) string

func IANAToWindowsTimezone added in v0.3.6

func IANAToWindowsTimezone(loc *time.Location) (string, bool)

IANAToWindowsTimezone maps IANA timezone locations to their Windows equivalents.

func NewMalformedError added in v0.3.6

func NewMalformedError(line, character int, err error) error

NewMalformedError wraps err with line and character context when err is non-nil.

func SetGeo added in v0.3.3

func SetGeo[T GeoType](c SetPropertyOwner, lat T, lng T, params ...PropertyParameter)

func ToText

func ToText(s string) string

func WindowsTimezoneToIANA added in v0.3.6

func WindowsTimezoneToIANA(tzid string) *time.Location

WindowsTimezoneToIANA maps Windows timezone names to their IANA equivalents.

func WithCustomClient added in v0.3.2

func WithCustomClient(client *http.Client) *http.Client

func WithCustomRequest added in v0.3.2

func WithCustomRequest(request *http.Request) *http.Request

Types

type Action

type Action string
const (
	ActionAudio     Action = "AUDIO"
	ActionDisplay   Action = "DISPLAY"
	ActionEmail     Action = "EMAIL"
	ActionProcedure Action = "PROCEDURE"
)

type Attendee

type Attendee struct {
	IANAProperty
}

func (*Attendee) Email

func (p *Attendee) Email() string

func (*Attendee) ParticipationStatus

func (p *Attendee) ParticipationStatus() ParticipationStatus

type BaseProperty

type BaseProperty struct {
	IANAToken      string
	ICalParameters map[string][]string
	Value          string
}

func LooseParser added in v0.3.6

func LooseParser(rawLine ContentLine) (*BaseProperty, error)

LooseParser is an alternative to the default strict parser path used by ParseCalendar and ParseComponent. It preserves the property token and value when malformed parameters prevent a full parse.

func ParseProperty

func ParseProperty(contentLine ContentLine) (*BaseProperty, error)

ParseProperty parses a single RFC5545 content line using strict parsing rules.

func SkipPropertyParser added in v0.3.6

func SkipPropertyParser(rawLine ContentLine) (*BaseProperty, error)

SkipPropertyParser is an alternative to the default strict parser path used by ParseCalendar and ParseComponent. It returns parsed properties when the line is valid and skips malformed lines.

func (*BaseProperty) GetValueType added in v0.3.0

func (bp *BaseProperty) GetValueType() ValueDataType

func (*BaseProperty) SerializeTo added in v0.3.4

func (bp *BaseProperty) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type Calendar

type Calendar struct {
	Components         []Component
	CalendarProperties []CalendarProperty
	// contains filtered or unexported fields
}

func NewCalendar

func NewCalendar() *Calendar

func NewCalendarFor

func NewCalendarFor(service string) *Calendar

func NewCalendarWithOptions added in v0.3.6

func NewCalendarWithOptions(options ...any) (*Calendar, error)

NewCalendarWithOptions constructs a calendar with sane parser defaults and optional overrides.

func ParseCalendar

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

func ParseCalendarFromUrl added in v0.3.2

func ParseCalendarFromUrl(url string, opts ...any) (*Calendar, error)

func ParseCalendarWithOptions added in v0.3.3

func ParseCalendarWithOptions(r io.Reader, options ...any) (*Calendar, error)

func (*Calendar) AddBusy added in v0.2.4

func (cal *Calendar) AddBusy(id string) *VBusy

func (*Calendar) AddEvent

func (calendar *Calendar) AddEvent(id string) *VEvent

func (*Calendar) AddJournal added in v0.2.4

func (cal *Calendar) AddJournal(id string) *VJournal

func (*Calendar) AddTimezone added in v0.2.4

func (cal *Calendar) AddTimezone(id string) *VTimezone

func (*Calendar) AddTodo added in v0.2.4

func (cal *Calendar) AddTodo(id string) *VTodo

func (*Calendar) AddVAlarm added in v0.2.4

func (cal *Calendar) AddVAlarm(e *VAlarm)

func (*Calendar) AddVBusy added in v0.2.4

func (cal *Calendar) AddVBusy(e *VBusy)

func (*Calendar) AddVEvent

func (calendar *Calendar) AddVEvent(e *VEvent)

func (*Calendar) AddVJournal added in v0.2.4

func (cal *Calendar) AddVJournal(e *VJournal)

func (*Calendar) AddVTimezone added in v0.2.4

func (cal *Calendar) AddVTimezone(e *VTimezone)

func (*Calendar) AddVTodo added in v0.2.4

func (cal *Calendar) AddVTodo(e *VTodo)

func (*Calendar) Alarms added in v0.2.4

func (cal *Calendar) Alarms() []*VAlarm

func (*Calendar) Busys added in v0.2.4

func (cal *Calendar) Busys() []*VBusy

func (*Calendar) Events

func (calendar *Calendar) Events() (r []*VEvent)

func (*Calendar) Journals added in v0.2.4

func (cal *Calendar) Journals() []*VJournal

func (*Calendar) RemoveEvent added in v0.2.1

func (calendar *Calendar) RemoveEvent(id string)

func (*Calendar) Serialize

func (cal *Calendar) Serialize(ops ...any) string

Serialize converts the Calendar and all its nested components (such as events, timezones, and alarms) into a single, fully formatted iCalendar string.

It accepts optional configuration arguments (ops) to customize the output layout, such as setting custom line folding lengths or overriding line endings.

Note on Line Endings: By default, uses Unix-style line endings (LF). To strictly comply with the iCalendar specification (RFC 5545), which requires Windows-style line endings (CRLF) for broad compatibility with clients like Outlook and Apple Calendar, pass the explicit formatting option:

cal.Serialize(ics.WithNewLineWindows)

func (*Calendar) SerializeTo

func (cal *Calendar) SerializeTo(w io.Writer, ops ...any) error

func (*Calendar) SetCalscale

func (cal *Calendar) SetCalscale(s string, params ...PropertyParameter)

func (*Calendar) SetColor

func (cal *Calendar) SetColor(s string, params ...PropertyParameter)

func (*Calendar) SetDescription

func (cal *Calendar) SetDescription(s string, params ...PropertyParameter)

func (*Calendar) SetLastModified

func (cal *Calendar) SetLastModified(t time.Time, params ...PropertyParameter)

func (*Calendar) SetMethod

func (cal *Calendar) SetMethod(method Method, params ...PropertyParameter)

SetMethod sets the METHOD property for the calendar.

These should be used with caution when creating simple iCal (.ics) files. The iCalendar specification is defined in RFC 5545. It refers to RFC 5546, which defines the ADD method as allowing the Organizer to add one or more new instances to an existing VEVENT, VTODO, or VJOURNAL using a single iTIP message. The UID must be that of the existing event/task/journal.

If you include METHOD: ADD in your .ics file (or use SetMethod(MethodAdd)), it is required to refer to existing calendar components. If you are simply writing .ics files to import into calendaring tools, it is not likely that you will want to use this option. Notably, the Apple Calendar program will reject events in .ics files that have this set if they do not refer to existing calendar events; some other calendars (like Microsoft Outlook) have a more permissive import process and will accept them.

func (*Calendar) SetName

func (cal *Calendar) SetName(s string, params ...PropertyParameter)

func (*Calendar) SetProductId

func (cal *Calendar) SetProductId(s string, params ...PropertyParameter)

func (*Calendar) SetRefreshInterval

func (cal *Calendar) SetRefreshInterval(s string, params ...PropertyParameter)

func (*Calendar) SetTimezoneId

func (cal *Calendar) SetTimezoneId(s string, params ...PropertyParameter)

func (*Calendar) SetTzid

func (cal *Calendar) SetTzid(s string, params ...PropertyParameter)

func (*Calendar) SetUrl

func (cal *Calendar) SetUrl(s string, params ...PropertyParameter)

func (*Calendar) SetVersion

func (cal *Calendar) SetVersion(s string, params ...PropertyParameter)

func (*Calendar) SetXPublishedTTL

func (cal *Calendar) SetXPublishedTTL(s string, params ...PropertyParameter)

func (*Calendar) SetXWRCalDesc

func (cal *Calendar) SetXWRCalDesc(s string, params ...PropertyParameter)

func (*Calendar) SetXWRCalID

func (cal *Calendar) SetXWRCalID(s string, params ...PropertyParameter)

func (*Calendar) SetXWRCalName

func (cal *Calendar) SetXWRCalName(s string, params ...PropertyParameter)

func (*Calendar) SetXWRTimezone

func (cal *Calendar) SetXWRTimezone(s string, params ...PropertyParameter)

func (*Calendar) Timezones added in v0.2.4

func (cal *Calendar) Timezones() []*VTimezone

func (*Calendar) Todos added in v0.2.4

func (cal *Calendar) Todos() []*VTodo

type CalendarOption added in v0.3.6

type CalendarOption func(*Calendar) error

CalendarOption provides functional options for Calendar construction.

func WithProductId added in v0.3.6

func WithProductId(productID string, params ...PropertyParameter) CalendarOption

WithProductId sets the calendar product identifier.

func WithVersion added in v0.3.6

func WithVersion(version string, params ...PropertyParameter) CalendarOption

WithVersion sets the calendar version.

type CalendarProperty

type CalendarProperty struct {
	BaseProperty
}

type CalendarStream

type CalendarStream struct {
	// contains filtered or unexported fields
}

func NewCalendarStream

func NewCalendarStream(r io.Reader) *CalendarStream

func (*CalendarStream) ReadLine

func (cs *CalendarStream) ReadLine() (*ContentLine, int, error)

type CalendarUserType

type CalendarUserType string
const (
	CalendarUserTypeIndividual CalendarUserType = "INDIVIDUAL"
	CalendarUserTypeGroup      CalendarUserType = "GROUP"
	CalendarUserTypeResource   CalendarUserType = "RESOURCE"
	CalendarUserTypeRoom       CalendarUserType = "ROOM"
	CalendarUserTypeUnknown    CalendarUserType = "UNKNOWN"
)

func (CalendarUserType) KeyValue

func (cut CalendarUserType) KeyValue(_ ...interface{}) (string, []string)

type Classification

type Classification string
const (
	ClassificationPublic       Classification = "PUBLIC"
	ClassificationPrivate      Classification = "PRIVATE"
	ClassificationConfidential Classification = "CONFIDENTIAL"
)

type Component

type Component interface {
	UnknownPropertiesIANAProperties() []IANAProperty
	SubComponents() []Component
	SerializeTo(b io.Writer, serialConfig *SerializationConfiguration) error
}

Component To determine what this is please use a type switch or typecast to each of: - *VEvent - *VTodo - *VBusy - *VJournal

func GeneralParseComponent

func GeneralParseComponent(cs *CalendarStream, startLine *BaseProperty) (Component, error)

func GeneralParseComponentWithOptions added in v0.3.6

func GeneralParseComponentWithOptions(cs *CalendarStream, startLine *BaseProperty, opts ...any) (Component, error)

type ComponentBase

type ComponentBase struct {
	Properties []IANAProperty
	Components []Component
	// contains filtered or unexported fields
}

func NewComponent added in v0.2.4

func NewComponent(uniqueId string) ComponentBase

func ParseComponent

func ParseComponent(cs *CalendarStream, startLine *BaseProperty) (ComponentBase, error)

func ParseComponentWithOptions added in v0.3.6

func ParseComponentWithOptions(cs *CalendarStream, startLine *BaseProperty, opts ...any) (ComponentBase, error)

func (*ComponentBase) AddAttachment added in v0.2.4

func (cb *ComponentBase) AddAttachment(s string, params ...PropertyParameter)

func (*ComponentBase) AddAttachmentBinary added in v0.2.4

func (cb *ComponentBase) AddAttachmentBinary(binary []byte, contentType string)

func (*ComponentBase) AddAttachmentURL added in v0.2.4

func (cb *ComponentBase) AddAttachmentURL(uri string, contentType string)

func (*ComponentBase) AddAttendee added in v0.2.4

func (cb *ComponentBase) AddAttendee(s string, params ...PropertyParameter)

func (*ComponentBase) AddCategory added in v0.2.4

func (cb *ComponentBase) AddCategory(s string, params ...PropertyParameter)

func (*ComponentBase) AddComment added in v0.2.4

func (cb *ComponentBase) AddComment(s string, params ...PropertyParameter)

func (*ComponentBase) AddExdate added in v0.2.4

func (cb *ComponentBase) AddExdate(s string, params ...PropertyParameter)

func (*ComponentBase) AddExrule added in v0.2.4

func (cb *ComponentBase) AddExrule(s string, params ...PropertyParameter)

func (*ComponentBase) AddProperty

func (cb *ComponentBase) AddProperty(property ComponentProperty, value string, params ...PropertyParameter)

AddProperty appends a property

func (*ComponentBase) AddRdate added in v0.2.4

func (cb *ComponentBase) AddRdate(s string, params ...PropertyParameter)

func (*ComponentBase) AddRrule added in v0.2.4

func (cb *ComponentBase) AddRrule(s string, params ...PropertyParameter)

func (*ComponentBase) Attendees added in v0.2.4

func (cb *ComponentBase) Attendees() []*Attendee

func (*ComponentBase) GetAllDayStartAt added in v0.2.4

func (cb *ComponentBase) GetAllDayStartAt() (time.Time, error)

func (*ComponentBase) GetDtStampTime added in v0.2.4

func (cb *ComponentBase) GetDtStampTime() (time.Time, error)

func (*ComponentBase) GetEndAt added in v0.3.2

func (cb *ComponentBase) GetEndAt() (time.Time, error)

func (*ComponentBase) GetExDates added in v0.3.5

func (cb *ComponentBase) GetExDates() ([]time.Time, error)

GetExDates returns all EXDATE times, handling both comma-separated values within a single property and multiple EXDATE properties.

func (*ComponentBase) GetExRules added in v0.3.5

func (cb *ComponentBase) GetExRules() ([]*RecurrenceRule, error)

GetExRules returns all EXRULE properties parsed into RecurrenceRule structs.

func (*ComponentBase) GetLastModifiedAt added in v0.2.4

func (cb *ComponentBase) GetLastModifiedAt() (time.Time, error)

func (*ComponentBase) GetProperties added in v0.3.2

func (cb *ComponentBase) GetProperties(componentProperty ComponentProperty) []*IANAProperty

GetProperties returns all matches for the particular property you're after. Please consider using: ComponentProperty.Singular/ComponentProperty.Multiple to determine if GetProperty or GetProperties is more appropriate.

func (*ComponentBase) GetProperty

func (cb *ComponentBase) GetProperty(componentProperty ComponentProperty) *IANAProperty

GetProperty returns the first match for the particular property you're after. Please consider using: ComponentProperty.Required to determine if GetProperty or GetProperties is more appropriate.

func (*ComponentBase) GetRDates added in v0.3.5

func (cb *ComponentBase) GetRDates() ([]time.Time, error)

GetRDates returns all RDATE times, handling both comma-separated values within a single property and multiple RDATE properties.

func (*ComponentBase) GetRRules added in v0.3.5

func (cb *ComponentBase) GetRRules() ([]*RecurrenceRule, error)

GetRRules returns all RRULE properties parsed into RecurrenceRule structs.

func (*ComponentBase) GetRecurrenceID added in v0.3.5

func (cb *ComponentBase) GetRecurrenceID() (time.Time, error)

GetRecurrenceID returns the RECURRENCE-ID property as a time.Time.

func (*ComponentBase) GetStartAt added in v0.2.4

func (cb *ComponentBase) GetStartAt() (time.Time, error)

func (*ComponentBase) HasProperty added in v0.3.2

func (cb *ComponentBase) HasProperty(componentProperty ComponentProperty) bool

HasProperty returns true if a component property is in the component.

func (*ComponentBase) Id added in v0.2.4

func (cb *ComponentBase) Id() string

func (*ComponentBase) RemoveProperty added in v0.3.2

func (cb *ComponentBase) RemoveProperty(removeProp ComponentProperty) []IANAProperty

RemoveProperty removes from the component all properties that is of a particular property type, returning an slice of removed entities

func (*ComponentBase) RemovePropertyByFunc added in v0.3.2

func (cb *ComponentBase) RemovePropertyByFunc(removeProp ComponentProperty, remove func(p IANAProperty) bool) []IANAProperty

RemovePropertyByFunc removes from the component all properties that has a particular property type and the function remove returns true for

func (*ComponentBase) RemovePropertyByValue added in v0.3.2

func (cb *ComponentBase) RemovePropertyByValue(removeProp ComponentProperty, value string) []IANAProperty

RemovePropertyByValue removes properties matching the given type and value. It returns a slice of the removed properties.

func (*ComponentBase) ReplaceProperty added in v0.3.2

func (cb *ComponentBase) ReplaceProperty(property ComponentProperty, value string, params ...PropertyParameter) []IANAProperty

ReplaceProperty replaces all matches of the particular property you're setting, otherwise adds it. Returns a slice of removed properties. Please consider using: ComponentProperty.Singular/ComponentProperty.Multiple to determine if AddProperty, SetProperty or ReplaceProperty is more appropriate.

func (*ComponentBase) SetAllDayEndAt added in v0.2.4

func (cb *ComponentBase) SetAllDayEndAt(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetAllDayStartAt added in v0.2.4

func (cb *ComponentBase) SetAllDayStartAt(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetClass added in v0.2.4

func (cb *ComponentBase) SetClass(c Classification, params ...PropertyParameter)

func (*ComponentBase) SetColor added in v0.2.4

func (cb *ComponentBase) SetColor(s string, params ...PropertyParameter)

func (*ComponentBase) SetCreatedTime added in v0.2.4

func (cb *ComponentBase) SetCreatedTime(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetDescription added in v0.2.4

func (cb *ComponentBase) SetDescription(s string, params ...PropertyParameter)

func (*ComponentBase) SetDtStampTime added in v0.2.4

func (cb *ComponentBase) SetDtStampTime(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetDuration added in v0.3.2

func (cb *ComponentBase) SetDuration(d time.Duration) error

SetDuration updates the duration of an event. This function will set either the end or start time of an event depending what is already given. The duration defines the length of a event relative to start or end time.

Notice: It will not set the DURATION key of the ics - only DTSTART and DTEND will be affected.

func (*ComponentBase) SetEndAt added in v0.3.2

func (cb *ComponentBase) SetEndAt(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetLocation added in v0.2.4

func (cb *ComponentBase) SetLocation(s string, params ...PropertyParameter)

func (*ComponentBase) SetModifiedAt added in v0.2.4

func (cb *ComponentBase) SetModifiedAt(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetOrganizer added in v0.2.4

func (cb *ComponentBase) SetOrganizer(s string, params ...PropertyParameter)

func (*ComponentBase) SetProperty

func (cb *ComponentBase) SetProperty(property ComponentProperty, value string, params ...PropertyParameter)

SetProperty replaces the first match for the particular property you're setting, otherwise adds it. Please consider using: ComponentProperty.Singular/ComponentProperty.Multiple to determine if AddProperty, SetProperty or ReplaceProperty is more appropriate.

func (*ComponentBase) SetSequence added in v0.2.4

func (cb *ComponentBase) SetSequence(seq int, params ...PropertyParameter)

func (*ComponentBase) SetStartAt added in v0.2.4

func (cb *ComponentBase) SetStartAt(t time.Time, params ...PropertyParameter)

func (*ComponentBase) SetStatus added in v0.2.4

func (cb *ComponentBase) SetStatus(s ObjectStatus, params ...PropertyParameter)

func (*ComponentBase) SetSummary added in v0.2.4

func (cb *ComponentBase) SetSummary(s string, params ...PropertyParameter)

func (*ComponentBase) SetURL added in v0.2.4

func (cb *ComponentBase) SetURL(s string, params ...PropertyParameter)

func (*ComponentBase) SubComponents

func (cb *ComponentBase) SubComponents() []Component

func (*ComponentBase) UnknownPropertiesIANAProperties

func (cb *ComponentBase) UnknownPropertiesIANAProperties() []IANAProperty

type ComponentProperty

type ComponentProperty Property

func ComponentPropertyExtended added in v0.3.2

func ComponentPropertyExtended(s string) ComponentProperty

func (ComponentProperty) Exclusive added in v0.3.2

func (cp ComponentProperty) Exclusive(c Component) []ComponentProperty

Exclusive returns the ComponentProperty's using the rules from the RFC as to if one or more existing properties are prohibiting this one If unspecified or incomplete, it returns false. -- This list is incomplete verify source. Happy to take PRs with reference iana-prop and x-props are not covered as it would always be true and require an exhaustive list.

func (ComponentProperty) Multiple added in v0.3.2

func (cp ComponentProperty) Multiple(c Component) bool

Multiple returns the rules from the RFC as to if the spec states explicitly if multiple are allowed iana-prop and x-props are not covered as it would always be true and require an exhaustive list.

func (ComponentProperty) Optional added in v0.3.2

func (cp ComponentProperty) Optional(c Component) bool

Optional returns the rules from the RFC as to if the spec states that if these are optional iana-prop and x-props are not covered as it would always be true and require an exhaustive list.

func (ComponentProperty) Required added in v0.3.2

func (cp ComponentProperty) Required(c Component) bool

Required returns the rules from the RFC as to if they are required or not for any particular component type If unspecified or incomplete, it returns false. -- This list is incomplete verify source. Happy to take PRs with reference iana-prop and x-props are not covered as it would always be true and require an exhaustive list.

func (ComponentProperty) Singular added in v0.3.2

func (cp ComponentProperty) Singular(c Component) bool

Singular returns the rules from the RFC as to if the spec states that if "Must not occur more than once" iana-prop and x-props are not covered as it would always be true and require an exhaustive list.

type ComponentType

type ComponentType string
const (
	ComponentVCalendar ComponentType = "VCALENDAR"
	ComponentVEvent    ComponentType = "VEVENT"
	ComponentVTodo     ComponentType = "VTODO"
	ComponentVJournal  ComponentType = "VJOURNAL"
	ComponentVFreeBusy ComponentType = "VFREEBUSY"
	ComponentVTimezone ComponentType = "VTIMEZONE"
	ComponentVAlarm    ComponentType = "VALARM"
	ComponentStandard  ComponentType = "STANDARD"
	ComponentDaylight  ComponentType = "DAYLIGHT"
)

type ContentLine

type ContentLine string

type Daylight

type Daylight struct {
	ComponentBase
}

func ParseDaylight

func ParseDaylight(cs *CalendarStream, startLine *BaseProperty) *Daylight

func ParseDaylightWithError added in v0.3.2

func ParseDaylightWithError(cs *CalendarStream, startLine *BaseProperty) (*Daylight, error)

func (*Daylight) Serialize

func (daylight *Daylight) Serialize(serialConfig *SerializationConfiguration) string

func (*Daylight) SerializeTo added in v0.3.2

func (daylight *Daylight) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type FreeBusyTimeType

type FreeBusyTimeType string
const (
	FreeBusyTimeTypeFree            FreeBusyTimeType = "FREE"
	FreeBusyTimeTypeBusy            FreeBusyTimeType = "BUSY"
	FreeBusyTimeTypeBusyUnavailable FreeBusyTimeType = "BUSY-UNAVAILABLE"
	FreeBusyTimeTypeBusyTentative   FreeBusyTimeType = "BUSY-TENTATIVE"
)

type Frequency added in v0.3.5

type Frequency string
const (
	FrequencySecondly Frequency = "SECONDLY"
	FrequencyMinutely Frequency = "MINUTELY"
	FrequencyHourly   Frequency = "HOURLY"
	FrequencyDaily    Frequency = "DAILY"
	FrequencyWeekly   Frequency = "WEEKLY"
	FrequencyMonthly  Frequency = "MONTHLY"
	FrequencyYearly   Frequency = "YEARLY"
)

type GeneralComponent

type GeneralComponent struct {
	ComponentBase
	Token string
}

func ParseGeneralComponent

func ParseGeneralComponent(cs *CalendarStream, startLine *BaseProperty) *GeneralComponent

func ParseGeneralComponentWithError added in v0.3.2

func ParseGeneralComponentWithError(cs *CalendarStream, startLine *BaseProperty) (*GeneralComponent, error)

func (*GeneralComponent) Serialize

func (general *GeneralComponent) Serialize(serialConfig *SerializationConfiguration) string

func (*GeneralComponent) SerializeTo added in v0.3.2

func (general *GeneralComponent) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type GeoType added in v0.3.3

type GeoType interface {
	~float32 | ~float64 | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~string
}

type HttpClientLike added in v0.3.2

type HttpClientLike interface {
	Do(req *http.Request) (*http.Response, error)
}

type IANAProperty

type IANAProperty struct {
	BaseProperty
}

type KeyValues

type KeyValues struct {
	Key   string
	Value []string
}

func (*KeyValues) KeyValue

func (kv *KeyValues) KeyValue(_ ...interface{}) (string, []string)

type MalformedError added in v0.3.6

type MalformedError struct {
	Err       error
	Line      int
	Character int
	HasLine   bool
	HasChar   bool
}

MalformedError reports a parse failure with optional line and character context.

func (*MalformedError) Error added in v0.3.6

func (e *MalformedError) Error() string

func (*MalformedError) Unwrap added in v0.3.6

func (e *MalformedError) Unwrap() error

type Method

type Method string

Method represents the iCalendar METHOD property.

These should be used with caution when creating simple iCal (.ics) files. The iCalendar specification is defined in RFC 5545. It refers to RFC 5546, which defines the ADD method as allowing the Organizer to add one or more new instances to an existing VEVENT, VTODO, or VJOURNAL using a single iTIP message. The UID must be that of the existing event/task/journal.

If you include METHOD: ADD in your .ics file (or use SetMethod(MethodAdd)), it is required to refer to existing calendar components. If you are simply writing .ics files to import into calendaring tools, it is not likely that you will want to use this option. Notably, the Apple Calendar program will reject events in .ics files that have this set if they do not refer to existing calendar events; some other calendars (like Microsoft Outlook) have a more permissive import process and will accept them.

const (
	MethodPublish        Method = "PUBLISH"
	MethodRequest        Method = "REQUEST"
	MethodReply          Method = "REPLY"
	MethodAdd            Method = "ADD"
	MethodCancel         Method = "CANCEL"
	MethodRefresh        Method = "REFRESH"
	MethodCounter        Method = "COUNTER"
	MethodDeclinecounter Method = "DECLINECOUNTER"
)

type ObjectStatus

type ObjectStatus string
const (
	ObjectStatusTentative   ObjectStatus = "TENTATIVE"
	ObjectStatusConfirmed   ObjectStatus = "CONFIRMED"
	ObjectStatusCancelled   ObjectStatus = "CANCELLED"
	ObjectStatusNeedsAction ObjectStatus = "NEEDS-ACTION"
	ObjectStatusCompleted   ObjectStatus = "COMPLETED"
	ObjectStatusInProcess   ObjectStatus = "IN-PROCESS"
	ObjectStatusDraft       ObjectStatus = "DRAFT"
	ObjectStatusFinal       ObjectStatus = "FINAL"
)

func (ObjectStatus) KeyValue

func (ps ObjectStatus) KeyValue(_ ...interface{}) (string, []string)

type Parameter

type Parameter string
const (
	ParameterAltrep              Parameter = "ALTREP"
	ParameterCn                  Parameter = "CN"
	ParameterCutype              Parameter = "CUTYPE"
	ParameterDelegatedFrom       Parameter = "DELEGATED-FROM"
	ParameterDelegatedTo         Parameter = "DELEGATED-TO"
	ParameterDir                 Parameter = "DIR"
	ParameterEncoding            Parameter = "ENCODING"
	ParameterFmttype             Parameter = "FMTTYPE"
	ParameterFbtype              Parameter = "FBTYPE"
	ParameterLanguage            Parameter = "LANGUAGE"
	ParameterMember              Parameter = "MEMBER"
	ParameterParticipationStatus Parameter = "PARTSTAT"
	ParameterRange               Parameter = "RANGE"
	ParameterRelated             Parameter = "RELATED"
	ParameterReltype             Parameter = "RELTYPE"
	ParameterRole                Parameter = "ROLE"
	ParameterRsvp                Parameter = "RSVP"
	ParameterSentBy              Parameter = "SENT-BY"
	ParameterTzid                Parameter = "TZID"
	ParameterValue               Parameter = "VALUE"
)

func (Parameter) IsQuoted added in v0.3.2

func (p Parameter) IsQuoted() bool

type ParseOption added in v0.3.3

type ParseOption func(*Calendar) error

ParseOption provides functional options for ParseCalendar

func WithPropertyParser added in v0.3.6

func WithPropertyParser(f PropertyParser) ParseOption

WithPropertyParser allows custom handling of property parse errors. It is a convenience wrapper; ParseCalendarWithOptions also accepts PropertyParser directly. When a content line fails to parse (e.g. due to malformed parameter names), the parser is called with the raw content line.

The parser can:

  • Return (*BaseProperty, nil) to use a recovered/replacement property
  • Return (nil, nil) to skip the property silently
  • Return (nil, err) to abort parsing with the error

Without this option, any property parse error aborts the entire calendar parse. This is useful for real-world ICS feeds that contain non-RFC-compliant properties (e.g. parameter names with underscores).

func WithTimezoneMapper added in v0.3.6

func WithTimezoneMapper(mapper TimezoneMapper) ParseOption

WithTimezoneMapper configures how Windows timezone identifiers are mapped during parsing.

func WithUnknownPropertyHandler added in v0.3.3

func WithUnknownPropertyHandler(f func(*Calendar, string, *BaseProperty) error) ParseOption

WithUnknownPropertyHandler allows custom handling of unknown properties

func WithWindowsTimezoneMapping added in v0.3.6

func WithWindowsTimezoneMapping() ParseOption

WithWindowsTimezoneMapping enables mapping of Windows timezone names to IANA equivalents during calendar parsing.

type ParticipationRole

type ParticipationRole string
const (
	ParticipationRoleChair          ParticipationRole = "CHAIR"
	ParticipationRoleReqParticipant ParticipationRole = "REQ-PARTICIPANT"
	ParticipationRoleOptParticipant ParticipationRole = "OPT-PARTICIPANT"
	ParticipationRoleNonParticipant ParticipationRole = "NON-PARTICIPANT"
)

func (ParticipationRole) KeyValue

func (pr ParticipationRole) KeyValue(_ ...interface{}) (string, []string)

type ParticipationStatus

type ParticipationStatus string
const (
	ParticipationStatusNeedsAction ParticipationStatus = "NEEDS-ACTION"
	ParticipationStatusAccepted    ParticipationStatus = "ACCEPTED"
	ParticipationStatusDeclined    ParticipationStatus = "DECLINED"
	ParticipationStatusTentative   ParticipationStatus = "TENTATIVE"
	ParticipationStatusDelegated   ParticipationStatus = "DELEGATED"
	ParticipationStatusCompleted   ParticipationStatus = "COMPLETED"
	ParticipationStatusInProcess   ParticipationStatus = "IN-PROCESS"
)

func (ParticipationStatus) KeyValue

func (ps ParticipationStatus) KeyValue(_ ...interface{}) (string, []string)

type Property

type Property string
const (
	PropertyCalscale        Property = "CALSCALE" // TEXT
	PropertyMethod          Property = "METHOD"   // TEXT
	PropertyProductId       Property = "PRODID"   // TEXT
	PropertyVersion         Property = "VERSION"  // TEXT
	PropertyXPublishedTTL   Property = "X-PUBLISHED-TTL"
	PropertyRefreshInterval Property = "REFRESH-INTERVAL;VALUE=DURATION"
	PropertyAttach          Property = "ATTACH"
	PropertyCategories      Property = "CATEGORIES"  // TEXT
	PropertyClass           Property = "CLASS"       // TEXT
	PropertyColor           Property = "COLOR"       // TEXT
	PropertyComment         Property = "COMMENT"     // TEXT
	PropertyDescription     Property = "DESCRIPTION" // TEXT
	PropertyXWRCalDesc      Property = "X-WR-CALDESC"
	PropertyGeo             Property = "GEO"
	PropertyLocation        Property = "LOCATION" // TEXT
	PropertyPercentComplete Property = "PERCENT-COMPLETE"
	PropertyPriority        Property = "PRIORITY"
	PropertyResources       Property = "RESOURCES" // TEXT
	PropertyStatus          Property = "STATUS"    // TEXT
	PropertySummary         Property = "SUMMARY"   // TEXT
	PropertyCompleted       Property = "COMPLETED"
	PropertyDtend           Property = "DTEND"
	PropertyDue             Property = "DUE"
	PropertyDtstart         Property = "DTSTART"
	PropertyDuration        Property = "DURATION"
	PropertyFreebusy        Property = "FREEBUSY"
	PropertyTransp          Property = "TRANSP" // TEXT
	PropertyTzid            Property = "TZID"   // TEXT
	PropertyTzname          Property = "TZNAME" // TEXT
	PropertyTzoffsetfrom    Property = "TZOFFSETFROM"
	PropertyTzoffsetto      Property = "TZOFFSETTO"
	PropertyTzurl           Property = "TZURL"
	PropertyAttendee        Property = "ATTENDEE"
	PropertyContact         Property = "CONTACT" // TEXT
	PropertyOrganizer       Property = "ORGANIZER"
	PropertyRecurrenceId    Property = "RECURRENCE-ID"
	PropertyRelatedTo       Property = "RELATED-TO" // TEXT
	PropertyUrl             Property = "URL"
	PropertyUid             Property = "UID" // TEXT
	PropertyExdate          Property = "EXDATE"
	PropertyExrule          Property = "EXRULE"
	PropertyRdate           Property = "RDATE"
	PropertyRrule           Property = "RRULE"
	PropertyAction          Property = "ACTION" // TEXT
	PropertyRepeat          Property = "REPEAT"
	PropertyTrigger         Property = "TRIGGER"
	PropertyCreated         Property = "CREATED"
	PropertyDtstamp         Property = "DTSTAMP"
	PropertyLastModified    Property = "LAST-MODIFIED"
	PropertyRequestStatus   Property = "REQUEST-STATUS" // TEXT
	PropertyName            Property = "NAME"
	PropertyXWRCalName      Property = "X-WR-CALNAME"
	PropertyXWRTimezone     Property = "X-WR-TIMEZONE"
	PropertySequence        Property = "SEQUENCE"
	PropertyXWRCalID        Property = "X-WR-RELCALID"
	PropertyTimezoneId      Property = "TIMEZONE-ID"
	PropertySource          Property = "SOURCE"
)

type PropertyParameter

type PropertyParameter interface {
	KeyValue(s ...interface{}) (string, []string)
}

func WithAlternativeRepresentation added in v0.3.2

func WithAlternativeRepresentation(uri *url.URL) PropertyParameter

WithAlternativeRepresentation takes what must be a valid URI in quotation marks

func WithCN

func WithCN(cn string) PropertyParameter

func WithEncoding

func WithEncoding(encType string) PropertyParameter

func WithFmtType

func WithFmtType(contentType string) PropertyParameter

func WithRSVP

func WithRSVP(b bool) PropertyParameter

func WithTZID added in v0.3.2

func WithTZID(tzid string) PropertyParameter

func WithValue

func WithValue(kind string) PropertyParameter

type PropertyParser added in v0.3.6

type PropertyParser func(rawLine ContentLine) (*BaseProperty, error)

PropertyParser is an optional replacement parser for malformed content lines. It receives the raw content line and can either recover, skip, or abort.

func FallbackParser added in v0.3.6

func FallbackParser(fallback PropertyParser, fallbacks ...PropertyParser) PropertyParser

FallbackParser builds an alternative to the default strict parser path used by ParseCalendar and ParseComponent. It tries the strict parser first, then each supplied fallback parser in order.

type RecurrenceRule added in v0.3.5

type RecurrenceRule struct {
	Freq          Frequency
	Until         time.Time // zero value if unset
	UntilDateOnly bool      // true when UNTIL was parsed from a date-only value (no time component)
	Count         int       // 0 if unset
	Interval      int       // defaults to 1
	BySecond      []int
	ByMinute      []int
	ByHour        []int
	ByDay         []WeekdayNum
	ByMonthDay    []int
	ByYearDay     []int
	ByWeekNo      []int
	ByMonth       []int
	BySetPos      []int
	Wkst          Weekday // empty string if unset
}

RecurrenceRule represents a parsed RRULE as defined in RFC 5545 Section 3.3.10.

func ParseRecurrenceRule added in v0.3.5

func ParseRecurrenceRule(s string) (*RecurrenceRule, error)

ParseRecurrenceRule parses an RRULE value string (without the "RRULE:" prefix) into a RecurrenceRule struct.

func (*RecurrenceRule) String added in v0.3.5

func (r *RecurrenceRule) String() string

String serializes the RecurrenceRule back to RRULE value format (without "RRULE:" prefix).

type RelationshipType

type RelationshipType string
const (
	RelationshipTypeChild   RelationshipType = "CHILD"
	RelationshipTypeParent  RelationshipType = "PARENT"
	RelationshipTypeSibling RelationshipType = "SIBLING"
)

type SerializationConfiguration added in v0.3.2

type SerializationConfiguration struct {
	MaxLength         int
	NewLine           string
	PropertyMaxLength int
	// contains filtered or unexported fields
}

type SerializationOption added in v0.3.6

type SerializationOption func(*SerializationConfiguration) error

SerializationOption provides functional options for Serialize and SerializeTo.

func WithSerializationTimezoneMapper added in v0.3.6

func WithSerializationTimezoneMapper(mapper TimezoneSerializationMapper) SerializationOption

WithSerializationTimezoneMapper configures how timezone identifiers are mapped during serialization.

func WithWindowsTimezoneMappingForSerialization added in v0.3.6

func WithWindowsTimezoneMappingForSerialization() SerializationOption

WithWindowsTimezoneMappingForSerialization enables mapping of IANA timezone names to Windows equivalents during serialization.

type SetPropertyOwner added in v0.3.3

type SetPropertyOwner interface {
	SetProperty(property ComponentProperty, value string, params ...PropertyParameter)
}

type Standard

type Standard struct {
	ComponentBase
}

func NewStandard added in v0.3.2

func NewStandard() *Standard

func ParseStandard

func ParseStandard(cs *CalendarStream, startLine *BaseProperty) *Standard

func ParseStandardWithError added in v0.3.2

func ParseStandardWithError(cs *CalendarStream, startLine *BaseProperty) (*Standard, error)

func (*Standard) Serialize

func (standard *Standard) Serialize(serialConfig *SerializationConfiguration) string

func (*Standard) SerializeTo added in v0.3.2

func (standard *Standard) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type TimeTransparency

type TimeTransparency string
const (
	TransparencyOpaque      TimeTransparency = "OPAQUE" // default
	TransparencyTransparent TimeTransparency = "TRANSPARENT"
)

type TimezoneMapper added in v0.3.6

type TimezoneMapper func(string) *time.Location

TimezoneMapper maps a timezone identifier to a loaded time.Location. A nil return means the mapper did not handle the input.

type TimezoneSerializationMapper added in v0.3.6

type TimezoneSerializationMapper func(*time.Location) (string, bool)

TimezoneSerializationMapper maps a time.Location to a serialized timezone identifier.

type VAlarm

type VAlarm struct {
	ComponentBase
}

func NewAlarm added in v0.2.4

func NewAlarm(_ string) *VAlarm

NewAlarm creates a new VALARM component. Note: The string parameter is unused as VALARM components do not have a UID property per RFC 5545.

func ParseVAlarm

func ParseVAlarm(cs *CalendarStream, startLine *BaseProperty) *VAlarm

func ParseVAlarmWithError added in v0.3.2

func ParseVAlarmWithError(cs *CalendarStream, startLine *BaseProperty) (*VAlarm, error)

func (*VAlarm) Serialize

func (c *VAlarm) Serialize(serialConfig *SerializationConfiguration) string

func (*VAlarm) SerializeTo added in v0.3.2

func (c *VAlarm) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

func (*VAlarm) SetAction

func (c *VAlarm) SetAction(a Action, params ...PropertyParameter)

func (*VAlarm) SetTrigger

func (c *VAlarm) SetTrigger(s string, params ...PropertyParameter)

type VBusy

type VBusy struct {
	ComponentBase
}

func NewBusy added in v0.2.4

func NewBusy(uniqueId string) *VBusy

func ParseVBusy

func ParseVBusy(cs *CalendarStream, startLine *BaseProperty) *VBusy

func ParseVBusyWithError added in v0.3.2

func ParseVBusyWithError(cs *CalendarStream, startLine *BaseProperty) (*VBusy, error)

func (*VBusy) Serialize

func (busy *VBusy) Serialize(serialConfig *SerializationConfiguration) string

func (*VBusy) SerializeTo added in v0.3.2

func (busy *VBusy) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type VEvent

type VEvent struct {
	ComponentBase
}

func NewEvent

func NewEvent(uniqueId string) *VEvent

func ParseVEvent

func ParseVEvent(cs *CalendarStream, startLine *BaseProperty) *VEvent

func ParseVEventWithError added in v0.3.2

func ParseVEventWithError(cs *CalendarStream, startLine *BaseProperty) (*VEvent, error)

func (*VEvent) AddAlarm

func (event *VEvent) AddAlarm() *VAlarm

func (*VEvent) AddVAlarm added in v0.2.4

func (event *VEvent) AddVAlarm(a *VAlarm)

func (*VEvent) Alarms

func (event *VEvent) Alarms() []*VAlarm

func (*VEvent) GetAllDayDueAt added in v0.3.6

func (todo *VEvent) GetAllDayDueAt() (time.Time, error)

func (*VEvent) GetAllDayEndAt

func (event *VEvent) GetAllDayEndAt() (time.Time, error)

func (*VEvent) Serialize

func (event *VEvent) Serialize(serialConfig *SerializationConfiguration) string

func (*VEvent) SerializeTo added in v0.3.2

func (event *VEvent) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

func (*VEvent) SetEndAt

func (event *VEvent) SetEndAt(t time.Time, props ...PropertyParameter)

func (*VEvent) SetGeo

func (event *VEvent) SetGeo(lat interface{}, lng interface{}, params ...PropertyParameter)

SetGeo sets the geo property

func (*VEvent) SetLastModifiedAt added in v0.2.3

func (event *VEvent) SetLastModifiedAt(t time.Time, props ...PropertyParameter)

func (*VEvent) SetPriority added in v0.2.4

func (event *VEvent) SetPriority(p int, params ...PropertyParameter)

func (*VEvent) SetResources added in v0.2.4

func (event *VEvent) SetResources(r string, params ...PropertyParameter)

func (*VEvent) SetTimeTransparency

func (event *VEvent) SetTimeTransparency(v TimeTransparency, params ...PropertyParameter)

type VJournal

type VJournal struct {
	ComponentBase
}

func NewJournal added in v0.2.4

func NewJournal(uniqueId string) *VJournal

func ParseVJournal

func ParseVJournal(cs *CalendarStream, startLine *BaseProperty) *VJournal

func ParseVJournalWithError added in v0.3.2

func ParseVJournalWithError(cs *CalendarStream, startLine *BaseProperty) (*VJournal, error)

func (*VJournal) Serialize

func (journal *VJournal) Serialize(serialConfig *SerializationConfiguration) string

func (*VJournal) SerializeTo added in v0.3.2

func (journal *VJournal) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type VTimezone

type VTimezone struct {
	ComponentBase
}

func NewTimezone added in v0.2.4

func NewTimezone(tzId string) *VTimezone

func ParseVTimezone

func ParseVTimezone(cs *CalendarStream, startLine *BaseProperty) *VTimezone

func ParseVTimezoneWithError added in v0.3.2

func ParseVTimezoneWithError(cs *CalendarStream, startLine *BaseProperty) (*VTimezone, error)

func (*VTimezone) AddStandard added in v0.3.2

func (timezone *VTimezone) AddStandard() *Standard

func (*VTimezone) Serialize

func (timezone *VTimezone) Serialize(serialConfig *SerializationConfiguration) string

func (*VTimezone) SerializeTo added in v0.3.2

func (timezone *VTimezone) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

type VTodo

type VTodo struct {
	ComponentBase
}

func NewTodo added in v0.2.4

func NewTodo(uniqueId string) *VTodo

func ParseVTodo

func ParseVTodo(cs *CalendarStream, startLine *BaseProperty) *VTodo

func ParseVTodoWithError added in v0.3.2

func ParseVTodoWithError(cs *CalendarStream, startLine *BaseProperty) (*VTodo, error)

func (*VTodo) AddAlarm added in v0.2.4

func (todo *VTodo) AddAlarm() *VAlarm

func (*VTodo) AddVAlarm added in v0.2.4

func (todo *VTodo) AddVAlarm(a *VAlarm)

func (*VTodo) Alarms added in v0.2.4

func (todo *VTodo) Alarms() []*VAlarm

func (*VTodo) GetDueAt added in v0.2.4

func (todo *VTodo) GetDueAt() (time.Time, error)

TODO verify that due is only relevant to VTodo if not move to ComponentBase.

func (*VTodo) Serialize

func (todo *VTodo) Serialize(serialConfig *SerializationConfiguration) string

func (*VTodo) SerializeTo added in v0.3.2

func (todo *VTodo) SerializeTo(w io.Writer, serialConfig *SerializationConfiguration) error

func (*VTodo) SetAllDayCompletedAt added in v0.2.4

func (todo *VTodo) SetAllDayCompletedAt(t time.Time, params ...PropertyParameter)

func (*VTodo) SetAllDayDueAt added in v0.2.4

func (todo *VTodo) SetAllDayDueAt(t time.Time, params ...PropertyParameter)

func (*VTodo) SetCompletedAt added in v0.2.4

func (todo *VTodo) SetCompletedAt(t time.Time, params ...PropertyParameter)

func (*VTodo) SetDueAt added in v0.2.4

func (todo *VTodo) SetDueAt(t time.Time, params ...PropertyParameter)

func (*VTodo) SetDuration added in v0.2.4

func (todo *VTodo) SetDuration(d time.Duration) error

SetDuration updates the duration of an event. This function will set either the end or start time of an event depending what is already given. The duration defines the length of a event relative to start or end time.

Notice: It will not set the DURATION key of the ics - only DTSTART and DTEND will be affected.

func (*VTodo) SetGeo added in v0.2.4

func (todo *VTodo) SetGeo(lat interface{}, lng interface{}, params ...PropertyParameter)

SetGeo sets the geo property

func (*VTodo) SetPercentComplete added in v0.2.4

func (todo *VTodo) SetPercentComplete(p int, params ...PropertyParameter)

func (*VTodo) SetPriority added in v0.2.4

func (todo *VTodo) SetPriority(p int, params ...PropertyParameter)

func (*VTodo) SetResources added in v0.2.4

func (todo *VTodo) SetResources(r string, params ...PropertyParameter)

type ValueDataType

type ValueDataType string
const (
	ValueDataTypeBinary     ValueDataType = "BINARY"
	ValueDataTypeBoolean    ValueDataType = "BOOLEAN"
	ValueDataTypeCalAddress ValueDataType = "CAL-ADDRESS"
	ValueDataTypeDate       ValueDataType = "DATE"
	ValueDataTypeDateTime   ValueDataType = "DATE-TIME"
	ValueDataTypeDuration   ValueDataType = "DURATION"
	ValueDataTypeFloat      ValueDataType = "FLOAT"
	ValueDataTypeInteger    ValueDataType = "INTEGER"
	ValueDataTypePeriod     ValueDataType = "PERIOD"
	ValueDataTypeRecur      ValueDataType = "RECUR"
	ValueDataTypeText       ValueDataType = "TEXT"
	ValueDataTypeTime       ValueDataType = "TIME"
	ValueDataTypeUri        ValueDataType = "URI"
	ValueDataTypeUtcOffset  ValueDataType = "UTC-OFFSET"
)

type Weekday added in v0.3.5

type Weekday string
const (
	WeekdaySunday    Weekday = "SU"
	WeekdayMonday    Weekday = "MO"
	WeekdayTuesday   Weekday = "TU"
	WeekdayWednesday Weekday = "WE"
	WeekdayThursday  Weekday = "TH"
	WeekdayFriday    Weekday = "FR"
	WeekdaySaturday  Weekday = "SA"
)

type WeekdayNum added in v0.3.5

type WeekdayNum struct {
	OrdWeek int
	Day     Weekday
}

WeekdayNum represents a weekday with an optional ordinal (e.g., -1SU = last Sunday, 2MO = second Monday). OrdWeek of 0 means no ordinal was specified.

func (WeekdayNum) String added in v0.3.5

func (wdn WeekdayNum) String() string

type WithLineLength added in v0.3.2

type WithLineLength int

type WithNewLine added in v0.3.2

type WithNewLine string
const (
	WithNewLineUnix    WithNewLine = "\n"
	WithNewLineWindows WithNewLine = "\r\n"
)

Directories

Path Synopsis
cmd
issues/test97_1 command
extensions
wg
wr

Jump to

Keyboard shortcuts

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